Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
" - The current process assumes the finals document is named finals_by_subject.pdf and is in the same folder as this process\n",
" - The output is a csv file with format: ['Season', 'Year', 'Major', 'Course', 'Section', 'Start', 'End', 'Building', 'Room_Number']\n",
" - Use \"jupyter nbconvert --to script FinalsParser.ipynb\" to convert the .ipynb file to a .py\n",
" - Run with \"python FinalsParser.py pathtoschedule.pdf\"\n",
"\n",
"TODO:\n",
"\n",
Expand All @@ -26,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 11,
"id": "c5584e3c-8c4d-4656-8699-383826a60509",
"metadata": {},
"outputs": [],
Expand All @@ -37,12 +38,13 @@
"import pandas as pd\n",
"import re\n",
"import calendar\n",
"import sys\n",
"debug_mode = False"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 12,
"id": "b89afdbc-6199-4ad8-bc03-467ea9a495ce",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -78,15 +80,15 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 13,
"id": "201b53c9-4435-4371-8463-cc06ec5a19dc",
"metadata": {},
"outputs": [],
"source": [
"def parser():\n",
" files = [f for f in os.listdir('.') if os.path.isfile(f)]\n",
" \n",
" reader = PdfReader(\"finals_schedule.pdf\")\n",
" if len(sys.argv) != 2:\n",
" raise Exception(\"Include file path to finals pdf as argument\")\n",
" reader = PdfReader(sys.argv[1])\n",
" number_of_pages = len(reader.pages)\n",
" \n",
" db_lines = []\n",
Expand Down Expand Up @@ -204,10 +206,11 @@
" done = False\n",
" for tmp_major in majors:\n",
" for section in sections:\n",
" if \"ALL\" in section:\n",
" start_time, end_time = handle_times(time1, time2, day, month, year)\n",
" db_lines.append([season, year, tmp_major, course, None, start_time, end_time, building, room])\n",
" all = True\n",
" for course in courses:\n",
" if \"ALL\" in section:\n",
" start_time, end_time = handle_times(time1, time2, day, month, year)\n",
" db_lines.append([season, year, tmp_major, course, None, start_time, end_time, building, room])\n",
" all = True\n",
" if all:\n",
" done = True\n",
" continue\n",
Expand Down Expand Up @@ -237,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 14,
"id": "c100e052-1d8a-432c-8fc2-0086cfd5d334",
"metadata": {},
"outputs": [],
Expand All @@ -259,14 +262,24 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 15,
"id": "e54bdf1b-ba2d-42dc-afbf-39efdcbc02c0",
"metadata": {},
"outputs": [],
"source": [
"db_lines = parser()\n",
"display_and_write_csv(db_lines)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8de91268-03fb-4f08-9e78-2c9fcb616ba1",
"metadata": {},
"outputs": [],
"source": [
"os.system(f'send_finals_to_api.py out.csv')"
]
}
],
"metadata": {
Expand Down
Binary file not shown.
18 changes: 15 additions & 3 deletions rpi_data/Finals_Parser/FinalsParser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
" - The current process assumes the finals document is named finals_by_subject.pdf and is in the same folder as this process\n",
" - The output is a csv file with format: ['Season', 'Year', 'Major', 'Course', 'Section', 'Start', 'End', 'Building', 'Room_Number']\n",
" - Use \"jupyter nbconvert --to script FinalsParser.ipynb\" to convert the .ipynb file to a .py\n",
" - Run with \"python FinalsParser.py pathtoschedule.pdf\"\n",
"\n",
"TODO:\n",
"\n",
Expand All @@ -37,6 +38,7 @@
"import pandas as pd\n",
"import re\n",
"import calendar\n",
"import sys\n",
"debug_mode = False"
]
},
Expand Down Expand Up @@ -84,9 +86,9 @@
"outputs": [],
"source": [
"def parser():\n",
" files = [f for f in os.listdir('.') if os.path.isfile(f)]\n",
" \n",
" reader = PdfReader(\"finals_schedule.pdf\")\n",
" if len(sys.argv) != 2:\n",
" raise Exception(\"Include file path to finals pdf as argument\")\n",
" reader = PdfReader(sys.argv[1])\n",
" number_of_pages = len(reader.pages)\n",
" \n",
" db_lines = []\n",
Expand Down Expand Up @@ -268,6 +270,16 @@
"db_lines = parser()\n",
"display_and_write_csv(db_lines)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8de91268-03fb-4f08-9e78-2c9fcb616ba1",
"metadata": {},
"outputs": [],
"source": [
"os.system(f'send_finals_to_api.py out.csv')"
]
}
],
"metadata": {
Expand Down
20 changes: 14 additions & 6 deletions rpi_data/Finals_Parser/FinalsParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# - The current process assumes the finals document is named finals_by_subject.pdf and is in the same folder as this process
# - The output is a csv file with format: ['Season', 'Year', 'Major', 'Course', 'Section', 'Start', 'End', 'Building', 'Room_Number']
# - Use "jupyter nbconvert --to script FinalsParser.ipynb" to convert the .ipynb file to a .py
# - Run with "python FinalsParser.py pathtoschedule.pdf"
#
# TODO:
#
Expand All @@ -28,6 +29,7 @@
import pandas as pd
import re
import calendar
import sys
debug_mode = False


Expand Down Expand Up @@ -57,19 +59,19 @@ def handle_times(start_text, end_text, day, month, year):
# Construct and return the datetime object
start_text = year + str(month_num) + day + str(start_nums[0]) + ":" + str(start_nums[1])
end_text = year + str(month_num) + day + str(end_nums[0]) + ":" + str(end_nums[1])
text_fmt = '%Y%m%d%H:%M'
start_time = datetime.strptime(start_text, text_fmt)
end_time = datetime.strptime(end_text, text_fmt)
format = '%Y%m%d%H:%M'
start_time = datetime.strptime(start_text, format)
end_time = datetime.strptime(end_text, format)
return start_time, end_time


# In[13]:


def parser():
files = [f for f in os.listdir('.') if os.path.isfile(f)]

reader = PdfReader("finals_schedule.pdf")
if len(sys.argv) != 2:
raise Exception("Include file path to finals pdf as argument")
reader = PdfReader(sys.argv[1])
number_of_pages = len(reader.pages)

db_lines = []
Expand Down Expand Up @@ -243,3 +245,9 @@ def display_and_write_csv(db_lines):
db_lines = parser()
display_and_write_csv(db_lines)


# In[ ]:


os.system(f'send_finals_to_api.py out.csv')

Binary file removed rpi_data/Finals_Parser/finals.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions rpi_data/Finals_Parser/send_finals_to_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys
import requests

csv_loc = sys.argv[1]

url = 'http://localhost:8080/api/finals-database-support'


content = {
'file': (open(csv_loc, 'rb')),
}

response = requests.post(url,files=content)
print(response.text)
Loading