Skip to content

Commit

Permalink
updates for 2020 phase 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierian-Data committed Jun 19, 2020
1 parent 31f7adf commit 046bae0
Show file tree
Hide file tree
Showing 11 changed files with 2,227 additions and 157 deletions.
1,011 changes: 963 additions & 48 deletions 03-Methods and Functions/.ipynb_checkpoints/02-Functions-checkpoint.ipynb

Large diffs are not rendered by default.

1,013 changes: 964 additions & 49 deletions 03-Methods and Functions/02-Functions.ipynb

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions 08-Milestone Project - 2/00-Milestone-2-Warmup-Project.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
Expand All @@ -24,7 +26,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
Expand All @@ -45,7 +47,7 @@
}
],
"source": [
"# THe correct result is shown below, if you can't download ffrom Google Drive, \n",
"# THe correct result is shown below, if you can't download from Google Drive, \n",
"# we added the PDF file to the Exercise_Files folder already"
]
},
Expand All @@ -59,7 +61,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# You should get this phone number\n",
Expand All @@ -84,7 +88,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"## Task One: Grab the Google Drive Link from .csv File"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import csv"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -29,7 +40,9 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"data = open('Exercise_Files/find_the_link.csv',encoding=\"utf-8\")\n",
Expand All @@ -54,7 +67,9 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"link_list = []\n",
Expand Down Expand Up @@ -92,7 +107,9 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"link_str = ''\n",
Expand Down Expand Up @@ -130,7 +147,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import PyPDF2"
Expand All @@ -139,7 +158,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f = open('Exercise_Files/Find_the_Phone_Number.pdf','rb')"
Expand All @@ -148,7 +169,9 @@
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"pdf = PyPDF2.PdfFileReader(f)"
Expand Down Expand Up @@ -180,13 +203,76 @@
"source": [
"## Phone Number Matching\n",
"\n",
"Lot's of ways to do this, but you had to figure out the phone number was in format ###.###.####"
"Lot's of ways to do this, but you had to figure out the phone number was in format ###.###.####\n",
"\n",
"Hint: https://stackoverflow.com/questions/4697882/how-can-i-find-all-matches-to-a-regular-expression-in-python"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import re"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"pattern = r'\\d{3}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"all_text = ''\n",
"\n",
"for n in range(pdf.numPages):\n",
" \n",
" page = pdf.getPage(n)\n",
" page_text = page.extractText()\n",
" \n",
" all_text = all_text+' '+page_text"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"for match in re.finditer(pattern,all_text):\n",
" print(match)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you know the correct pattern:"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import re"
Expand All @@ -195,7 +281,9 @@
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"pattern = r'\\d{3}.\\d{3}.\\d{4}' "
Expand Down Expand Up @@ -253,7 +341,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
54 changes: 40 additions & 14 deletions 15-PDFs-and-Spreadsheets/00-Working-with-CSV-Files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import csv"
Expand All @@ -70,7 +72,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"data = open('example.csv')"
Expand Down Expand Up @@ -108,7 +112,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csv_data = csv.reader(data)"
Expand Down Expand Up @@ -153,7 +159,9 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"data = open('example.csv',encoding=\"utf-8\")\n",
Expand Down Expand Up @@ -255,7 +263,9 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"all_emails = []\n",
Expand Down Expand Up @@ -290,7 +300,9 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"full_names = []\n",
Expand Down Expand Up @@ -352,7 +364,9 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# newline controls how universal newlines works (it only applies to text\n",
Expand All @@ -363,7 +377,9 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csv_writer = csv.writer(file_to_output,delimiter=',')"
Expand Down Expand Up @@ -392,7 +408,9 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csv_writer.writerows([['1','2','3'],['4','5','6']])"
Expand All @@ -401,7 +419,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"file_to_output.close()"
Expand All @@ -418,7 +438,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f = open('to_save_file.csv','a',newline='')"
Expand All @@ -427,7 +449,9 @@
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csv_writer = csv.writer(f)"
Expand Down Expand Up @@ -456,7 +480,9 @@
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f.close()"
Expand Down Expand Up @@ -486,7 +512,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.6.6"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 046bae0

Please sign in to comment.