text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
input itself did have a comma and so if | 4,532.76 | 5.1 |
I go to my CSV file now notice that it's | 4,535.4 | 4.86 |
automatically been quoted for me so that | 4,537.86 | 3.96 |
subsequent reads from this file don't | 4,540.26 | 3.66 |
confuse that comma with the actual comma | 4,541.82 | 4.8 |
between Harry and his home well let me | 4,543.92 | 3.96 |
go ahead and run it a couple of more | 4,546.62 | 3.119 |
times let me go ahead and rerun python | 4,547.88 | 4.2 |
of students.pi let me go ahead and input | 4,549.739 | 4.92 |
this time Ron and his home as the | 4,552.08 | 5.22 |
borough let's go back to students.csv to | 4,554.659 | 4.801 |
see what it looks like now we see Ron | 4,557.3 | 3.66 |
comma the burrow has been added | 4,559.46 | 3.3 |
automatically to the file and let's do | 4,560.96 | 4.8 |
one more python of students.pi enter | 4,562.76 | 5.76 |
let's go ahead and give draco's name and | 4,565.76 | 5.04 |
his home which would be Malfoy Manor | 4,568.52 | 5.159 |
enter and if we go back to students.csv | 4,570.8 | 4.74 |
now we see that Draco is in the file | 4,573.679 | 3.841 |
itself and the library took care of not | 4,575.54 | 3.9 |
only writing each of those rows per the | 4,577.52 | 3.96 |
function's name it also handled the | 4,579.44 | 4.5 |
escaping so to speak of any strings that | 4,581.48 | 4.14 |
themselves contain the comma like | 4,583.94 | 3.96 |
Harry's own home well it turns out | 4,585.62 | 3.599 |
there's yet another way we we could | 4,587.9 | 3.12 |
implement this same program without | 4,589.219 | 4.081 |
having to worry about precisely that | 4,591.02 | 3.96 |
order again and again and just passing | 4,593.3 | 4.14 |
in a list it turns out if we're keeping | 4,594.98 | 4.38 |
track of what's the name and what's the | 4,597.44 | 3.36 |
home we could use something like a | 4,599.36 | 3.42 |
dictionary to associate those keys with | 4,600.8 | 3.66 |
those values so let me go ahead and back | 4,602.78 | 3.66 |
up and remove these students from the | 4,604.46 | 3.84 |
file leaving only the header row again | 4,606.44 | 4.2 |
named comma home and let me go over to | 4,608.3 | 4.32 |
students.pi and this time instead of | 4,610.64 | 4.2 |
using CSV writer I'm going to go ahead | 4,612.62 | 3.44 |
and use | 4,614.84 | 3.12 |
csv.dictriter which is a dictionary | 4,616.06 | 4 |
writer that's going to open the file in | 4,617.96 | 4.02 |
much the same way but rather than write | 4,620.06 | 5.46 |
a row as this list of name comma home | 4,621.98 | 6.3 |
what I'm now going to do is follows I'm | 4,625.52 | 5.88 |
going to first output an actual | 4,628.28 | 4.74 |
dictionary the first key of which is | 4,631.4 | 4.2 |
Name colon and then the value thereof is | 4,633.02 | 3.96 |
going to be the name that was typed in | 4,635.6 | 3.3 |
and I'm going to pass in a key of Home | 4,636.98 | 3.42 |
quote unquote the value of which of | 4,638.9 | 3.36 |
course is the home that was typed in but | 4,640.4 | 4.38 |
with dict writer I do need to give it a | 4,642.26 | 4.979 |
hint as to the order in which those | 4,644.78 | 4.919 |
columns are when writing it out so that | 4,647.239 | 4.44 |
subsequently they could be red even if | 4,649.699 | 4.441 |
those orderings change let me go ahead | 4,651.679 | 4.921 |
and pass in field names which is a | 4,654.14 | 5.22 |
second argument to dictwriter equals and | 4,656.6 | 4.98 |
then a list of the actual columns that I | 4,659.36 | 3.6 |
know are in this file which of course | 4,661.58 | 4.56 |
are name comma home those times in | 4,662.96 | 5.04 |
quotes because that's indeed the string | 4,666.14 | 4.38 |
names of the columns so to speak that I | 4,668 | 4.679 |
intend to write to in that file all | 4,670.52 | 3.84 |
right now let me go ahead and go to my | 4,672.679 | 3.601 |
terminal window run python of | 4,674.36 | 4.319 |
students.pi this time I'll type in | 4,676.28 | 4.62 |
Harry's name again I'll again type in | 4,678.679 | 5.52 |
number four comma privet Drive | 4,680.9 | 6.54 |
enter let's now go back to students.csv | 4,684.199 | 5.341 |
and voila parries back in the file and | 4,687.44 | 4.5 |
it's properly escaped or quoted I'm sure | 4,689.54 | 4.5 |
then if we do this again with Ron and | 4,691.94 | 4.5 |
the burrow and let's go ahead and run it | 4,694.04 | 5.34 |
one third time with Draco and Malfoy | 4,696.44 | 5.36 |
Manor enter let's go back to | 4,699.38 | 4.5 |
students.csv and Via this dictionary | 4,701.8 | 4.78 |
writer we now have all three of those | 4,703.88 | 5.58 |
students as well so whereas with CSV | 4,706.58 | 6.06 |
writer the onus is on us to pass in a | 4,709.46 | 5.279 |
list of all of the values we want to put | 4,712.64 | 4.14 |
from left to right with a dictionary | 4,714.739 | 4.081 |
writer technically they could be in any | 4,716.78 | 4.08 |
order in the dictionary in fact I could | 4,718.82 | 5.1 |
just have correctly done this passing in | 4,720.86 | 5.46 |
home followed by name but it's a | 4,723.92 | 4.38 |
dictionary and so the ordering in this | 4,726.32 | 3.899 |
case does not matter so long as the key | 4,728.3 | 3.18 |
is there and the value is there and | 4,730.219 | 3.421 |
because I have passed in field names as | 4,731.48 | 4.679 |
the second argument to dict writer it | 4,733.64 | 4.92 |
ensures that the library knows exactly | 4,736.159 | 5.161 |
which column contains name or home | 4,738.56 | 4.2 |
respectively | 4,741.32 | 3.899 |
are there any questions now on | 4,742.76 | 4.8 |
dictionary reading dictionary writing or | 4,745.219 | 4.801 |
csvs more generally | 4,747.56 | 5.46 |
India any specifics the specific | 4,750.02 | 5.46 |
situation for me to use a single | 4,753.02 | 4.639 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.