text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
columns are going to be and therefore
4,065.24
3.299
I'm naming my variables accordingly
4,066.74
4.319
however this is a good segue to one
4,068.539
5.101
final feature of reading csvs which is
4,071.059
4.56
that you don't have to rely on either
4,073.64
4.439
getting a row as a list and using
4,075.619
4.68
bracket zero or bracket one and you
4,078.079
4.02
don't have to unpack things manually in
4,080.299
3.901
this way we could actually be smarter
4,082.099
4.141
and start storing the names of these
4,084.2
4.74
columns in the CSV file itself and in
4,086.24
4.44
fact if any of you have ever opened a
4,088.94
4.02
spreadsheet file before be it in Excel
4,090.68
4.439
Apple Numbers Google spreadsheets or the
4,092.96
4.02
like all odds are you've noticed that
4,095.119
4.321
the first row very frequently is a
4,096.98
4.08
little different it actually is bold
4,099.44
3.419
face sometimes or it actually contains
4,101.06
4.199
the names of those columns the names of
4,102.859
4.681
those attributes below and we can do
4,105.259
4.801
this here and students.csv I don't have
4,107.54
4.319
to just keep assuming that the student's
4,110.06
3.9
name is first and that the student's
4,111.859
4.741
home is second I can explicitly bake
4,113.96
5.46
that information into the file just to
4,116.6
4.8
reduce the probability of mistakes down
4,119.42
3.96
the road I can literally use the first
4,121.4
5.16
row of this file and say name comma home
4,123.38
5.279
so notice that
4,126.56
4.32
name is not literally someone's name and
4,128.659
3.901
home is not literally someone's home it
4,130.88
4.319
is literally the words name and home
4,132.56
5.52
separated by a comma and if I now go
4,135.199
5.761
back into students.pi and don't use CSV
4,138.08
5.759
reader but instead I use a dictionary
4,140.96
6.54
reader I can actually treat my CSV file
4,143.839
5.52
even more flexibly not just for this but
4,147.5
4.08
for other examples too let me do this
4,149.359
5.041
instead of using a CSV reader let me use
4,151.58
6.36
a CSV dict reader which will now iterate
4,154.4
6.419
over the file top to bottom loading in
4,157.94
5.759
each line of text not as a list of
4,160.819
5.761
columns but as a dictionary of columns
4,163.699
4.62
what's nice about this is that it's
4,166.58
4.079
going to give me automatic access now to
4,168.319
4.86
those columns names I'm going to revert
4,170.659
5.52
to just saying for Row in reader and now
4,173.179
4.98
I'm going to append a name and a home
4,176.179
4.381
but how am I going to get access to the
4,178.159
5.881
current rows name and the current rows
4,180.56
6.659
home well earlier I use bracket zero for
4,184.04
4.56
the first and bracket one for the second
4,187.219
4.321
when I was using a reader a reader
4,188.6
5.34
returns lists addict reader or
4,191.54
4.92
dictionary reader returns dictionaries
4,193.94
5.88
one at a time and so if I want to access
4,196.46
5.759
the current Row's name I can say row
4,199.82
4.859
quote unquote name I can say here for
4,202.219
5.281
home row quote-unquote home and I now
4,204.679
4.801
have access to those same values the
4,207.5
3.239
only change I had to make to be clear
4,209.48
4.44
was in my CSV file I had to include on
4,210.739
5.701
the very first row little hints as to
4,213.92
4.98
what these columns are and if I now run
4,216.44
4.2
this code I think it should behave
4,218.9
3.42
pretty much the same python of
4,220.64
3.9
students.pi and indeed we get the same
4,222.32
5.76
sentences but now my code is more robust
4,224.54
6.179
against changes in this data if I were
4,228.08
5.28
to open the CSV file in Excel or Google
4,230.719
4.621
spreadsheets or apple numbers and for
4,233.36
3.9
whatever reason change the columns
4,235.34
3.54
around maybe this is a file that you're
4,237.26
2.939
sharing with someone else and just
4,238.88
3.24
because they decide to sort things
4,240.199
3.721
differently left to right by moving the
4,242.12
3
columns around
4,243.92
3.239
previously my code would have broken
4,245.12
4.14
because I was assuming that name is
4,247.159
4.5
always first and home is always second
4,249.26
6.06
but if I did this be it manually in one
4,251.659
5.461
of those programs or here home comma
4,255.32
4.08
name and suppose I reversed all of this
4,257.12
4.26
the home comes first followed by Harry
4,259.4
6.24
the borough then by Ron and then lastly
4,261.38
7.62
Malfoy Manor then Draco notice that my
4,265.64
5.28
file is now completely flipped the First
4,269
3.239
Column is now the second and the
4,270.92
3.779
second's the first but I took care to
4,272.239
5.101
update the header of that file the first
4,274.699
5.46
row notice my python code I'm not going
4,277.34
4.8
to touch it at all I'm going to rerun
4,280.159
5.281
python of students.pi and hit enter and
4,282.14
6.059
it still just works and this too is an
4,285.44
4.5
example of like coding defensively like
4,288.199
3.601
what if someone changes your CSV file
4,289.94
3.779
your data file ideally that won't happen
4,291.8
4.02
but even if it does now because I'm
4,293.719
4.44
using a dictionary reader that's going
4,295.82
5.46
to infer from that first row for me what
4,298.159
5.52