text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
in this file I'm going to go ahead and | 1,954.08 | 5.339 |
do this for line and file as before and | 1,955.58 | 5.819 |
now I have to be a bit clever here let | 1,959.419 | 4.921 |
me go back to students.csv looking at | 1,961.399 | 5.4 |
this file and it seems that on my loop | 1,964.34 | 4.199 |
on each iteration I'm going to get | 1,966.799 | 4.74 |
access to the whole line of text I'm not | 1,968.539 | 4.62 |
going to automatically get access to | 1,971.539 | 4.38 |
just Hermione or just Gryffindor recall | 1,973.159 | 4.441 |
that the loop is going to give me each | 1,975.919 | 4.681 |
full line of text so logically what | 1,977.6 | 5.28 |
would you propose that we do inside of a | 1,980.6 | 4.26 |
for Loop that's reading a whole line of | 1,982.88 | 3.539 |
text at once but we now want to get | 1,984.86 | 3.9 |
access to the individual values like | 1,986.419 | 4.681 |
Hermione and Gryffindor Harry and | 1,988.76 | 4.799 |
Gryffindor how do we go about taking one | 1,991.1 | 4.439 |
line of text and gaining access to those | 1,993.559 | 3.48 |
individual values do you think just | 1,995.539 | 3.24 |
instinctively even if you're not sure | 1,997.039 | 3.48 |
what the name of the functions would be | 1,998.779 | 4.561 |
you can access access it as you would | 2,000.519 | 4.561 |
and if you were using a dictionary like | 2,003.34 | 3.3 |
using a key and value | 2,005.08 | 3.54 |
so ideally we would access it using it a | 2,006.64 | 3.419 |
key in value but at this point in the | 2,008.62 | 3.84 |
story all we have is this Loop and this | 2,010.059 | 4.921 |
Loop is giving me one line of text that | 2,012.46 | 4.38 |
is the time I'm the programmer now I | 2,014.98 | 3.059 |
have to solve this there is no | 2,016.84 | 3.24 |
dictionary yet in question about another | 2,018.039 | 3.901 |
suggestion here | 2,020.08 | 4.319 |
um so you can somehow split the two | 2,021.94 | 5.219 |
words based on the comma yeah even if | 2,024.399 | 4.561 |
you're not quite sure what function is | 2,027.159 | 3.541 |
going to do this intuitively you want to | 2,028.96 | 3.24 |
take this whole line of text Hermione | 2,030.7 | 4.02 |
comma Gryffindor Harry comma Gryffindor | 2,032.2 | 5.04 |
and so forth and split that line into | 2,034.72 | 4.5 |
two pieces if you will and it turns out | 2,037.24 | 3.419 |
wonderfully the function we'll use is | 2,039.22 | 3.72 |
actually called split that can split on | 2,040.659 | 4.38 |
any characters but you can tell it what | 2,042.94 | 3.9 |
character to use so I'm going to go back | 2,045.039 | 4.741 |
into students.pi and inside of this Loop | 2,046.84 | 4.319 |
I'm going to go ahead and do this I'm | 2,049.78 | 3.359 |
going to take the current line I'm going | 2,051.159 | 4.2 |
to remove the white space at the end as | 2,053.139 | 4.5 |
always using R strip here and then | 2,055.359 | 4.141 |
whatever the result of that is I'm going | 2,057.639 | 4.861 |
to now call split and quote unquote | 2,059.5 | 6.24 |
comma so the split function or method | 2,062.5 | 6.839 |
comes with strings stirs in Python any | 2,065.74 | 6.659 |
stir has this method built in and if you | 2,069.339 | 5.461 |
pass in an argument like a comma what | 2,072.399 | 4.68 |
this strip split function will do is | 2,074.8 | 4.68 |
split that current string into one two | 2,077.079 | 5.1 |
three maybe more pieces by looking for | 2,079.48 | 4.8 |
that character again and again | 2,082.179 | 5.641 |
ultimately strip uh ultimately split is | 2,084.28 | 5.639 |
going to return to us a list of all of | 2,087.82 | 4.079 |
the individual parts to the left and to | 2,089.919 | 4.321 |
the right of those commas so I can give | 2,091.899 | 4.381 |
myself a variable called row here and | 2,094.24 | 3.72 |
this is a common Paradigm when you know | 2,096.28 | 3.18 |
you're iterating over a file | 2,097.96 | 4.5 |
specifically a CSV it's common to think | 2,099.46 | 6.6 |
of each line of it as being a row and | 2,102.46 | 5.52 |
each of the values they're in separated | 2,106.06 | 4.74 |
by commas as columns so to speak so I'm | 2,107.98 | 4.5 |
going to deliberately name my variable | 2,110.8 | 3.42 |
row just to be consistent with that | 2,112.48 | 4.2 |
convention and now what do I want to | 2,114.22 | 4.379 |
print well I'm going to go ahead and say | 2,116.68 | 5.939 |
this print how about the following in F | 2,118.599 | 7.081 |
string that starts with curly braces | 2,122.619 | 6 |
well how do I get access to the first | 2,125.68 | 4.98 |
thing in that row well the row is going | 2,128.619 | 4.201 |
to have how many parts two because if | 2,130.66 | 4.02 |
I'm splitting on commas and there's one | 2,132.82 | 3.96 |
comma per line that's going to give me a | 2,134.68 | 3.96 |
left part and a right part like Hermione | 2,136.78 | 4.92 |
and Gryffindor Harry and Gryffindor when | 2,138.64 | 5.459 |
I have a list like row how do I get | 2,141.7 | 4.8 |
access to individual values well I can | 2,144.099 | 6.421 |
do this I can say Row Bracket zero and | 2,146.5 | 5.64 |
that's going to go to the first element | 2,150.52 | 3.12 |
of the list which should hopefully be | 2,152.14 | 3.959 |
the student's name then after that I'm | 2,153.64 | 4.26 |
going to say is in and I'm going to have | 2,156.099 | 5.281 |
another curly brace here for Row Bracket | 2,157.9 | 5.34 |
one and then I'm going to close my whole | 2,161.38 | 3.84 |
quote so it looks a little cryptic at | 2,163.24 | 3.54 |
first glance but most of this is just F | 2,165.22 | 3.899 |
string syntax with curly braces to plug | 2,166.78 | 4.319 |
in values and what values am I plugging | 2,169.119 | 4.74 |
in well rho again is a list and it has | 2,171.099 | 5.581 |
two elements presumably Hermione in one | 2,173.859 | 4.74 |
and Gryffindor and the other and so | 2,176.68 | 4.8 |
forth so bracket zero is the first | 2,178.599 | 4.321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.