Skip to content

Commit 046bae0

Browse files
committed
updates for 2020 phase 2
1 parent 31f7adf commit 046bae0

11 files changed

+2227
-157
lines changed

Diff for: 03-Methods and Functions/.ipynb_checkpoints/02-Functions-checkpoint.ipynb

+963-48
Large diffs are not rendered by default.

Diff for: 03-Methods and Functions/02-Functions.ipynb

+964-49
Large diffs are not rendered by default.

Diff for: 08-Milestone Project - 2/00-Milestone-2-Warmup-Project.ipynb

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"metadata": {},
6+
"metadata": {
7+
"collapsed": true
8+
},
79
"outputs": [],
810
"source": []
911
}
@@ -24,7 +26,7 @@
2426
"name": "python",
2527
"nbconvert_exporter": "python",
2628
"pygments_lexer": "ipython3",
27-
"version": "3.7.4"
29+
"version": "3.6.6"
2830
}
2931
},
3032
"nbformat": 4,

Diff for: 15-PDFs-and-Spreadsheets/.ipynb_checkpoints/02-PDFs-Spreadsheets-Puzzle-checkpoint.ipynb

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
{
2525
"cell_type": "code",
2626
"execution_count": null,
27-
"metadata": {},
27+
"metadata": {
28+
"collapsed": true
29+
},
2830
"outputs": [],
2931
"source": []
3032
},
@@ -45,7 +47,7 @@
4547
}
4648
],
4749
"source": [
48-
"# THe correct result is shown below, if you can't download ffrom Google Drive, \n",
50+
"# THe correct result is shown below, if you can't download from Google Drive, \n",
4951
"# we added the PDF file to the Exercise_Files folder already"
5052
]
5153
},
@@ -59,7 +61,9 @@
5961
{
6062
"cell_type": "code",
6163
"execution_count": 1,
62-
"metadata": {},
64+
"metadata": {
65+
"collapsed": true
66+
},
6367
"outputs": [],
6468
"source": [
6569
"# You should get this phone number\n",
@@ -84,7 +88,7 @@
8488
"name": "python",
8589
"nbconvert_exporter": "python",
8690
"pygments_lexer": "ipython3",
87-
"version": "3.7.4"
91+
"version": "3.6.6"
8892
}
8993
},
9094
"nbformat": 4,

Diff for: 15-PDFs-and-Spreadsheets/.ipynb_checkpoints/03-PDFs-Spreadsheets-Puzzle-Solution-checkpoint.ipynb

+98-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
"## Task One: Grab the Google Drive Link from .csv File"
2020
]
2121
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {
26+
"collapsed": true
27+
},
28+
"outputs": [],
29+
"source": [
30+
"import csv"
31+
]
32+
},
2233
{
2334
"cell_type": "markdown",
2435
"metadata": {},
@@ -29,7 +40,9 @@
2940
{
3041
"cell_type": "code",
3142
"execution_count": 12,
32-
"metadata": {},
43+
"metadata": {
44+
"collapsed": true
45+
},
3346
"outputs": [],
3447
"source": [
3548
"data = open('Exercise_Files/find_the_link.csv',encoding=\"utf-8\")\n",
@@ -54,7 +67,9 @@
5467
{
5568
"cell_type": "code",
5669
"execution_count": 13,
57-
"metadata": {},
70+
"metadata": {
71+
"collapsed": true
72+
},
5873
"outputs": [],
5974
"source": [
6075
"link_list = []\n",
@@ -92,7 +107,9 @@
92107
{
93108
"cell_type": "code",
94109
"execution_count": 15,
95-
"metadata": {},
110+
"metadata": {
111+
"collapsed": true
112+
},
96113
"outputs": [],
97114
"source": [
98115
"link_str = ''\n",
@@ -130,7 +147,9 @@
130147
{
131148
"cell_type": "code",
132149
"execution_count": 19,
133-
"metadata": {},
150+
"metadata": {
151+
"collapsed": true
152+
},
134153
"outputs": [],
135154
"source": [
136155
"import PyPDF2"
@@ -139,7 +158,9 @@
139158
{
140159
"cell_type": "code",
141160
"execution_count": 20,
142-
"metadata": {},
161+
"metadata": {
162+
"collapsed": true
163+
},
143164
"outputs": [],
144165
"source": [
145166
"f = open('Exercise_Files/Find_the_Phone_Number.pdf','rb')"
@@ -148,7 +169,9 @@
148169
{
149170
"cell_type": "code",
150171
"execution_count": 21,
151-
"metadata": {},
172+
"metadata": {
173+
"collapsed": true
174+
},
152175
"outputs": [],
153176
"source": [
154177
"pdf = PyPDF2.PdfFileReader(f)"
@@ -180,13 +203,76 @@
180203
"source": [
181204
"## Phone Number Matching\n",
182205
"\n",
183-
"Lot's of ways to do this, but you had to figure out the phone number was in format ###.###.####"
206+
"Lot's of ways to do this, but you had to figure out the phone number was in format ###.###.####\n",
207+
"\n",
208+
"Hint: https://stackoverflow.com/questions/4697882/how-can-i-find-all-matches-to-a-regular-expression-in-python"
184209
]
185210
},
186211
{
187212
"cell_type": "code",
188-
"execution_count": 23,
213+
"execution_count": 1,
214+
"metadata": {
215+
"collapsed": true
216+
},
217+
"outputs": [],
218+
"source": [
219+
"import re"
220+
]
221+
},
222+
{
223+
"cell_type": "code",
224+
"execution_count": 2,
225+
"metadata": {
226+
"collapsed": true
227+
},
228+
"outputs": [],
229+
"source": [
230+
"pattern = r'\\d{3}'"
231+
]
232+
},
233+
{
234+
"cell_type": "code",
235+
"execution_count": null,
236+
"metadata": {
237+
"collapsed": true
238+
},
239+
"outputs": [],
240+
"source": [
241+
"all_text = ''\n",
242+
"\n",
243+
"for n in range(pdf.numPages):\n",
244+
" \n",
245+
" page = pdf.getPage(n)\n",
246+
" page_text = page.extractText()\n",
247+
" \n",
248+
" all_text = all_text+' '+page_text"
249+
]
250+
},
251+
{
252+
"cell_type": "code",
253+
"execution_count": null,
254+
"metadata": {
255+
"collapsed": true
256+
},
257+
"outputs": [],
258+
"source": [
259+
"for match in re.finditer(pattern,all_text):\n",
260+
" print(match)"
261+
]
262+
},
263+
{
264+
"cell_type": "markdown",
189265
"metadata": {},
266+
"source": [
267+
"Once you know the correct pattern:"
268+
]
269+
},
270+
{
271+
"cell_type": "code",
272+
"execution_count": 23,
273+
"metadata": {
274+
"collapsed": true
275+
},
190276
"outputs": [],
191277
"source": [
192278
"import re"
@@ -195,7 +281,9 @@
195281
{
196282
"cell_type": "code",
197283
"execution_count": 24,
198-
"metadata": {},
284+
"metadata": {
285+
"collapsed": true
286+
},
199287
"outputs": [],
200288
"source": [
201289
"pattern = r'\\d{3}.\\d{3}.\\d{4}' "
@@ -253,7 +341,7 @@
253341
"name": "python",
254342
"nbconvert_exporter": "python",
255343
"pygments_lexer": "ipython3",
256-
"version": "3.7.4"
344+
"version": "3.6.6"
257345
}
258346
},
259347
"nbformat": 4,

Diff for: 15-PDFs-and-Spreadsheets/00-Working-with-CSV-Files.ipynb

+40-14
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
{
5555
"cell_type": "code",
5656
"execution_count": 2,
57-
"metadata": {},
57+
"metadata": {
58+
"collapsed": true
59+
},
5860
"outputs": [],
5961
"source": [
6062
"import csv"
@@ -70,7 +72,9 @@
7072
{
7173
"cell_type": "code",
7274
"execution_count": 3,
73-
"metadata": {},
75+
"metadata": {
76+
"collapsed": true
77+
},
7478
"outputs": [],
7579
"source": [
7680
"data = open('example.csv')"
@@ -108,7 +112,9 @@
108112
{
109113
"cell_type": "code",
110114
"execution_count": 5,
111-
"metadata": {},
115+
"metadata": {
116+
"collapsed": true
117+
},
112118
"outputs": [],
113119
"source": [
114120
"csv_data = csv.reader(data)"
@@ -153,7 +159,9 @@
153159
{
154160
"cell_type": "code",
155161
"execution_count": 7,
156-
"metadata": {},
162+
"metadata": {
163+
"collapsed": true
164+
},
157165
"outputs": [],
158166
"source": [
159167
"data = open('example.csv',encoding=\"utf-8\")\n",
@@ -255,7 +263,9 @@
255263
{
256264
"cell_type": "code",
257265
"execution_count": 11,
258-
"metadata": {},
266+
"metadata": {
267+
"collapsed": true
268+
},
259269
"outputs": [],
260270
"source": [
261271
"all_emails = []\n",
@@ -290,7 +300,9 @@
290300
{
291301
"cell_type": "code",
292302
"execution_count": 13,
293-
"metadata": {},
303+
"metadata": {
304+
"collapsed": true
305+
},
294306
"outputs": [],
295307
"source": [
296308
"full_names = []\n",
@@ -352,7 +364,9 @@
352364
{
353365
"cell_type": "code",
354366
"execution_count": 15,
355-
"metadata": {},
367+
"metadata": {
368+
"collapsed": true
369+
},
356370
"outputs": [],
357371
"source": [
358372
"# newline controls how universal newlines works (it only applies to text\n",
@@ -363,7 +377,9 @@
363377
{
364378
"cell_type": "code",
365379
"execution_count": 16,
366-
"metadata": {},
380+
"metadata": {
381+
"collapsed": true
382+
},
367383
"outputs": [],
368384
"source": [
369385
"csv_writer = csv.writer(file_to_output,delimiter=',')"
@@ -392,7 +408,9 @@
392408
{
393409
"cell_type": "code",
394410
"execution_count": 18,
395-
"metadata": {},
411+
"metadata": {
412+
"collapsed": true
413+
},
396414
"outputs": [],
397415
"source": [
398416
"csv_writer.writerows([['1','2','3'],['4','5','6']])"
@@ -401,7 +419,9 @@
401419
{
402420
"cell_type": "code",
403421
"execution_count": 19,
404-
"metadata": {},
422+
"metadata": {
423+
"collapsed": true
424+
},
405425
"outputs": [],
406426
"source": [
407427
"file_to_output.close()"
@@ -418,7 +438,9 @@
418438
{
419439
"cell_type": "code",
420440
"execution_count": 20,
421-
"metadata": {},
441+
"metadata": {
442+
"collapsed": true
443+
},
422444
"outputs": [],
423445
"source": [
424446
"f = open('to_save_file.csv','a',newline='')"
@@ -427,7 +449,9 @@
427449
{
428450
"cell_type": "code",
429451
"execution_count": 21,
430-
"metadata": {},
452+
"metadata": {
453+
"collapsed": true
454+
},
431455
"outputs": [],
432456
"source": [
433457
"csv_writer = csv.writer(f)"
@@ -456,7 +480,9 @@
456480
{
457481
"cell_type": "code",
458482
"execution_count": 23,
459-
"metadata": {},
483+
"metadata": {
484+
"collapsed": true
485+
},
460486
"outputs": [],
461487
"source": [
462488
"f.close()"
@@ -486,7 +512,7 @@
486512
"name": "python",
487513
"nbconvert_exporter": "python",
488514
"pygments_lexer": "ipython3",
489-
"version": "3.7.4"
515+
"version": "3.6.6"
490516
}
491517
},
492518
"nbformat": 4,

0 commit comments

Comments
 (0)