text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
via CSV reader or a dict reader and then | 4,664.6 | 4.36 |
iterating over each of those names but | 4,667.159 | 3.121 |
we'll keep it simple and just do one | 4,668.96 | 3.8 |
name at a time but now what's kind of | 4,670.28 | 4.08 |
interesting here is if I go back to my | 4,672.76 | 3.24 |
terminal window window and clear it and | 4,674.36 | 4.4 |
run python of format. piy and hit enter | 4,676 | 4.8 |
I'm going to type in David space ma as | 4,678.76 | 4.64 |
before and I think we're still good but | 4,680.8 | 4.6 |
I'm also going to go ahead and do this | 4,683.4 | 5.839 |
python of format. py maen comma David | 4,685.4 | 5.88 |
with a space in between crossing my | 4,689.239 | 5.521 |
fingers and hit enter and voila that now | 4,691.28 | 6.56 |
has been fixed such a simple thing to be | 4,694.76 | 5.959 |
sure but it is so commonly necessary to | 4,697.84 | 5.28 |
clean up users input here we see at | 4,700.719 | 5.601 |
least one way to do so pretty easily now | 4,703.12 | 5.44 |
to be fair there's some problems here | 4,706.32 | 3.96 |
and in fact can someone imagine a | 4,708.56 | 3.84 |
scenario in which this code really | 4,710.28 | 4.919 |
doesn't fix the user's input what could | 4,712.4 | 6.319 |
still go wrong even with this fix in my | 4,715.199 | 6.881 |
code any thoughts if they type their in | 4,718.719 | 6.281 |
their name comma and then sign them oh | 4,722.08 | 4.68 |
and then something else yeah so let me | 4,725 | 3.92 |
let me try this for instance um let me | 4,726.76 | 4.84 |
go ahead and run a program and uh I am | 4,728.92 | 4.64 |
the only David men that I know but | 4,731.6 | 5.68 |
suppose I were uh uh let's say junior | 4,733.56 | 5.76 |
like this and it's common in English at | 4,737.28 | 3.56 |
least to sometimes put a comma there you | 4,739.32 | 2.919 |
don't necessarily need the comma but I'm | 4,740.84 | 3.56 |
one of those people who uses a comma | 4,742.239 | 4.801 |
that's now really really broken so I've | 4,744.4 | 5.239 |
broken some assumption there and so that | 4,747.04 | 4.32 |
could certainly go wrong here what else | 4,749.639 | 2.961 |
well let me go ahead and run this again | 4,751.36 | 4.44 |
and if I did ma comma David no space | 4,752.6 | 4.48 |
because I'm being a little sloppy I'm | 4,755.8 | 3.08 |
not paying attention which is going to | 4,757.08 | 3.32 |
happen when you have lots of users | 4,758.88 | 3.799 |
ultimately well this really broke now | 4,760.4 | 4.839 |
notice I have a value error and actual | 4,762.679 | 6.121 |
exception why well because split is | 4,765.239 | 5.241 |
supposed to be splitting the string into | 4,768.8 | 4.399 |
two strings by looking for the comma and | 4,770.48 | 4.96 |
a space but if there is no comma in | 4,773.199 | 4.601 |
space it can't split it into two things | 4,775.44 | 4.68 |
and the fact that I have two variables | 4,777.8 | 5 |
on the left but I'm only getting back | 4,780.12 | 5.16 |
one thing on the right means that I | 4,782.8 | 4.52 |
can't do this code quite as this so it's | 4,785.28 | 4.04 |
fragile to be sure but wouldn't it be | 4,787.32 | 3.76 |
nice if we could at least improve it for | 4,789.32 | 3.16 |
instance we now know some regular | 4,791.08 | 3.68 |
expression syntax what if I at least | 4,792.48 | 5.04 |
wanted to make this space optional well | 4,794.76 | 4.36 |
I could use my new found regular | 4,797.52 | 3.159 |
expression syntax and put a question | 4,799.12 | 4.599 |
mark question mark means zero or one of | 4,800.679 | 5.121 |
the things to the left what's the thing | 4,803.719 | 4.041 |
to the left it's literally a space I | 4,805.8 | 3.64 |
don't even need parentheses if there's | 4,807.76 | 4.12 |
just one thing there so that would be | 4,809.44 | 4.68 |
the start of a pattern that says I must | 4,811.88 | 4.359 |
have a comma and then I may or may not | 4,814.12 | 4.32 |
have a space zero or one spaces | 4,816.239 | 5.041 |
thereafter unfortunately the version of | 4,818.44 | 6.64 |
split that's built into the stir | 4,821.28 | 6.28 |
variable as in this case doesn't support | 4,825.08 | 4.079 |
regular Expressions if we want our | 4,827.56 | 3.28 |
regular Expressions we need to go use | 4,829.159 | 3.801 |
that Library here so let me go ahead and | 4,830.84 | 4.799 |
do this let me go in and leave this code | 4,832.96 | 4.8 |
AS is but go up to the top now and | 4,835.639 | 4.721 |
import re to import the library for | 4,837.76 | 5.2 |
regular expressions and now let me go | 4,840.36 | 4.879 |
ahead and start changing my Approach | 4,842.96 | 4.6 |
here I'm going to go ahead and do this | 4,845.239 | 3.881 |
I'm going to use the same function | 4,847.56 | 4.079 |
called re. search and I'm going to | 4,849.12 | 5.72 |
search for a pattern that I think will | 4,851.639 | 5.721 |
be last comma first so let me use my | 4,854.84 | 4.56 |
newfound regular expression syntax and | 4,857.36 | 4.44 |
represent a pattern for something like | 4,859.4 | 6.239 |
men comma space David how can I do this | 4,861.8 | 6.68 |
well inside of my quotes for re. search | 4,865.639 | 6.321 |
I'm going to have something so plus | 4,868.48 | 6.679 |
sorry I'm GNA have something so plus | 4,871.96 | 5.12 |
then I'm G to have a comma then I'm G to | 4,875.159 | 3.641 |
have a space then I'm going to have | 4,877.08 | 4.079 |
something plus now I'm going to | 4,878.8 | 4.64 |
preemptively refine this a little bit I | 4,881.159 | 3.801 |
want this whole pattern to start | 4,883.44 | 2.96 |
matching at the beginning of the user's | 4,884.96 | 3.239 |
input so I'm going to add the carrot | 4,886.4 | 4.16 |
right away and I want the end of the | 4,888.199 | 4.48 |
user's input to be matched as well so | 4,890.56 | 4 |
that I'm literally expecting any | 4,892.679 | 4.361 |
character one or more times then a comma | 4,894.56 | 4.599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.