text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
change our approach for instance like
3,600.24
4.26
one Paradigm that is not uncommon is to
3,602.16
5.28
use something a little more
3,604.5
5.52
a little less common like a vertical bar
3,607.44
4.679
so I could go in and change all of my
3,610.02
4.44
commas to Vertical bars that too could
3,612.119
4.021
eventually come back to bite Us in that
3,614.46
3.599
if my file eventually has vertical bar
3,616.14
3.9
somewhere it might still break so maybe
3,618.059
3.901
that's not the best approach I could
3,620.04
3.6
maybe do something like this I could
3,621.96
3.78
escape the data as I've done in the past
3,623.64
5.28
and maybe I could put quotes around any
3,625.74
6.18
English string that itself contains the
3,628.92
5.1
comma and that's fine I could do that
3,631.92
5.22
but then my code students.pi is going to
3,634.02
5.039
have to change too because I can't just
3,637.14
4.74
naively split on a comma Now I'm going
3,639.059
4.981
to have to be smarter about it I'm going
3,641.88
4.14
to have to take into account split only
3,644.04
4.38
on the commas that are not inside of
3,646.02
4.559
quotes and oh it's getting complicated
3,648.42
4.32
fast and at this point you need to take
3,650.579
3.661
a step back and consider you know what
3,652.74
3.66
if we're having this problem odds are
3,654.24
4.5
many other people before us have had the
3,656.4
5.04
same problem it is incredibly common to
3,658.74
4.74
store data in files it is incredibly
3,661.44
5.28
common to use CSV files specifically and
3,663.48
5.579
so you know what why don't we see if
3,666.72
4.74
there's a library in Python that exists
3,669.059
6.121
to read and or write CSV files rather
3,671.46
5.82
than reinvent a wheel so to speak let's
3,675.18
3.78
see if we can write better code by
3,677.28
3.36
standing on the shoulders of others who
3,678.96
3.599
have come before us programmers passed
3,680.64
4.08
and actually use their code to do the
3,682.559
4.26
reading and writing of csvs so we can
3,684.72
4.32
focus on the part of our problem that
3,686.819
4.381
you and I care about so let's propose
3,689.04
4.74
that we go back to our code here and see
3,691.2
5.159
how we might use the CSV Library indeed
3,693.78
5.519
within python there is a module called
3,696.359
6
CSV the documentation for it is at this
3,699.299
4.681
URL here in Python's official
3,702.359
3.181
documentation but there's a few
3,703.98
3.66
functions that are pretty readily
3,705.54
4.799
accessible if we just Dive Right In and
3,707.64
4.86
let me propose that we do this let me go
3,710.339
4.681
back to my code here and instead of
3,712.5
4.859
Reinventing this wheel and reading the
3,715.02
4.319
file line by line and splitting on
3,717.359
4.2
commas and dealing now with quotes and
3,719.339
4.681
privet drives and so forth let's do this
3,721.559
5.461
instead at the start of my program let
3,724.02
6.48
me go up and import the CSV module let's
3,727.02
5.64
use this library that someone else has
3,730.5
4.079
written that's dealing with all of these
3,732.66
4.139
Corner cases if you will I'm still going
3,734.579
4.621
to give myself a list initially empty in
3,736.799
4.201
which to store all these students but
3,739.2
3.599
I'm going to change my Approach here now
3,741
4.74
just a little bit when I open this file
3,742.799
6.121
with with let me go in here and change
3,745.74
5.28
this a little bit I'm going to go in
3,748.92
4.52
here now and say this
3,751.02
6.539
reader equals CSV dot reader passing in
3,753.44
6.46
file as input so it turns out if you
3,757.559
4.081
read the documentation for the CSV
3,759.9
4.02
module it comes with a function called
3,761.64
4.679
reader whose purpose in life is to read
3,763.92
5.52
a CSV file for you and figure out where
3,766.319
4.681
are the commas where are the quotes
3,769.44
3.78
where are all the the potential Corner
3,771
4.14
cases and just deal with them for you
3,773.22
3.899
you can override certain defaults or
3,775.14
3.54
assumptions in case you're using not a
3,777.119
3.48
comma but a pipe or something else but
3,778.68
3.659
by default I think it's just going to
3,780.599
4.74
work now how do I iterate over a reader
3,782.339
5.161
and not the raw file itself it's almost
3,785.339
4.26
the same the library allows you still to
3,787.5
6.059
do this for each row in the reader so
3,789.599
5.401
you're not iterating over the file
3,793.559
3.54
directly now you're iterating over the
3,795
3.72
reader which is again going to handle
3,797.099
4.02
all of the parsing of commas and new
3,798.72
4.619
lines and more for each row in the
3,801.119
4.801
reader what am I going to do well at the
3,803.339
4.381
moment I'm going to do this I'm going to
3,805.92
4.679
append to my students list the following
3,807.72
5.399
dictionary a dictionary that has a name
3,810.599
5.281
whose value is the current Row's First
3,813.119
5.641
Column and whose house or rather home
3,815.88
6.479
now is the Rose second column now it's
3,818.76
6.299
worth noting that the reader for each
3,822.359
4.861
line in the file indeed returns to me a
3,825.059
4.381
row but it returns to me a row that's a
3,827.22
4.079
list which is to say that the first
3,829.44
3.599
element of that list is going to be the
3,831.299
3.841