commit 9abf46002bc81bd6f9dea9b58f171d6d85a8431e Author: Alan Date: Wed Mar 30 09:07:46 2022 -0500 copying files to public repo diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce8c7f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +build diff --git a/README.md b/README.md new file mode 100644 index 0000000..c84f78f --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Course reserves cleanup script + +This python script ingests a CSV file as formatted by the LibWizard survey output from the current (12/01/2021) course reserves request survey. It takes the ingested data and splits up the requests to include only one item per row while maintaining the data of the item's requestor. Columns are also added for human post-processing of the data. + +The current version of the script does not allow for flexible outputs, nor does it have a GUI. + diff --git a/course_reserves_cleanup.zip b/course_reserves_cleanup.zip new file mode 100644 index 0000000..1361655 Binary files /dev/null and b/course_reserves_cleanup.zip differ diff --git a/dist/version_1/VCRUNTIME140.dll b/dist/version_1/VCRUNTIME140.dll new file mode 100644 index 0000000..c403a55 Binary files /dev/null and b/dist/version_1/VCRUNTIME140.dll differ diff --git a/dist/version_1/_asyncio.pyd b/dist/version_1/_asyncio.pyd new file mode 100644 index 0000000..9efdc64 Binary files /dev/null and b/dist/version_1/_asyncio.pyd differ diff --git a/dist/version_1/_bz2.pyd b/dist/version_1/_bz2.pyd new file mode 100644 index 0000000..3def009 Binary files /dev/null and b/dist/version_1/_bz2.pyd differ diff --git a/dist/version_1/_ctypes.pyd b/dist/version_1/_ctypes.pyd new file mode 100644 index 0000000..fa06b63 Binary files /dev/null and b/dist/version_1/_ctypes.pyd differ diff --git a/dist/version_1/_decimal.pyd b/dist/version_1/_decimal.pyd new file mode 100644 index 0000000..3c7b02f Binary files /dev/null and b/dist/version_1/_decimal.pyd differ diff --git a/dist/version_1/_hashlib.pyd b/dist/version_1/_hashlib.pyd new file mode 100644 index 0000000..9ed8fcf Binary files /dev/null and b/dist/version_1/_hashlib.pyd differ diff --git a/dist/version_1/_lzma.pyd b/dist/version_1/_lzma.pyd new file mode 100644 index 0000000..f1d5b47 Binary files /dev/null and b/dist/version_1/_lzma.pyd differ diff --git a/dist/version_1/_multiprocessing.pyd b/dist/version_1/_multiprocessing.pyd new file mode 100644 index 0000000..2f1ad3e Binary files /dev/null and b/dist/version_1/_multiprocessing.pyd differ diff --git a/dist/version_1/_overlapped.pyd b/dist/version_1/_overlapped.pyd new file mode 100644 index 0000000..dea1dbe Binary files /dev/null and b/dist/version_1/_overlapped.pyd differ diff --git a/dist/version_1/_queue.pyd b/dist/version_1/_queue.pyd new file mode 100644 index 0000000..c2b3161 Binary files /dev/null and b/dist/version_1/_queue.pyd differ diff --git a/dist/version_1/_socket.pyd b/dist/version_1/_socket.pyd new file mode 100644 index 0000000..0b17cc4 Binary files /dev/null and b/dist/version_1/_socket.pyd differ diff --git a/dist/version_1/_ssl.pyd b/dist/version_1/_ssl.pyd new file mode 100644 index 0000000..a9322db Binary files /dev/null and b/dist/version_1/_ssl.pyd differ diff --git a/dist/version_1/base_library.zip b/dist/version_1/base_library.zip new file mode 100644 index 0000000..0ae78b0 Binary files /dev/null and b/dist/version_1/base_library.zip differ diff --git a/dist/version_1/libcrypto-1_1.dll b/dist/version_1/libcrypto-1_1.dll new file mode 100644 index 0000000..42bffb9 Binary files /dev/null and b/dist/version_1/libcrypto-1_1.dll differ diff --git a/dist/version_1/libffi-7.dll b/dist/version_1/libffi-7.dll new file mode 100644 index 0000000..8fd2e5e Binary files /dev/null and b/dist/version_1/libffi-7.dll differ diff --git a/dist/version_1/libssl-1_1.dll b/dist/version_1/libssl-1_1.dll new file mode 100644 index 0000000..3aee360 Binary files /dev/null and b/dist/version_1/libssl-1_1.dll differ diff --git a/dist/version_1/pyexpat.pyd b/dist/version_1/pyexpat.pyd new file mode 100644 index 0000000..100cf6b Binary files /dev/null and b/dist/version_1/pyexpat.pyd differ diff --git a/dist/version_1/python39.dll b/dist/version_1/python39.dll new file mode 100644 index 0000000..9d7f9ca Binary files /dev/null and b/dist/version_1/python39.dll differ diff --git a/dist/version_1/select.pyd b/dist/version_1/select.pyd new file mode 100644 index 0000000..852ac61 Binary files /dev/null and b/dist/version_1/select.pyd differ diff --git a/dist/version_1/unicodedata.pyd b/dist/version_1/unicodedata.pyd new file mode 100644 index 0000000..b4a158e Binary files /dev/null and b/dist/version_1/unicodedata.pyd differ diff --git a/dist/version_1/version_1.exe b/dist/version_1/version_1.exe new file mode 100644 index 0000000..94b796e Binary files /dev/null and b/dist/version_1/version_1.exe differ diff --git a/version_1.py b/version_1.py new file mode 100644 index 0000000..ceae4da --- /dev/null +++ b/version_1.py @@ -0,0 +1,103 @@ +import csv +import re + +# current working script, runs from command line only + +def create_row(raw_input_row_list, extra_item_number, extra_item_index_dict, course_info_list, output_csv_list): + # creates new row for extra items + + new_row = course_info_list.copy() + # print(course_info_list) + # print(extra_item_index_dict[extra_item_number + 1]) + for index in extra_item_index_dict[extra_item_number + 1]: + + # print(index) + # print(new_row) + item = raw_input_row_list[index] + # print(item) + new_row.append(item) + # print(new_row) + output_csv_list.append(new_row) + +with open ('./report.csv', encoding="utf8") as input_csv: + input_reader = csv.reader(input_csv, delimiter=',') + data = list(input_reader) + +heading_row = data[0] + +extra_item_index_list = [] +for index, heading in enumerate(data[0]): + if "Another" in heading: + extra_item_index_list.append(index) + +empty_column_headers = ["Status", "File Name", "Notes"] + +course_details_list = ["Length of Reserve", "Full Name", "Course Number", "Course Title"] + +item_details = ["Material", "Author", "Title:", "Page", "Chapter"] + +course_details_index_list = [] + + +for course_detail in course_details_list: + for index, heading in enumerate(data[0]): + if (re.search(course_detail, heading) and (index not in course_details_index_list)): + course_details_index_list.append(index) + break + +extra_item_index_dict = {} +item_details_index_list = [] + +# need to split up item headings by item number +# +for index, heading in enumerate(data[0]): + for item_detail in item_details: + # needs handling for #10 + if (re.search("[1-9]*" + item_detail, heading) and (index not in item_details_index_list) and (index not in course_details_index_list) and ("Journal" not in heading)): + item_details_index_list.append(index) + # break + # extra_item_index_dict.update() + + +# split extra item index ref list into chunks by item and add to dictionary +x = 0 +item_number = 1 +for i in range(x,len(item_details_index_list),len(item_details)): + x = i + extra_item_index_dict.update({item_number:item_details_index_list[x:x+5]}) + item_number += 1 + + +output_csv_list = [] +output_csv_list.append(empty_column_headers + course_details_list + item_details) + +# need to create function for new row/item creation. func must take in course row data along with indices of the next item info and/or the item data in a list. row parsing could be separate from new row creation? +for row in data[1:]: + course_info = [] + new_row_first = [] + for item in empty_column_headers: + new_row_first.append("") + course_info.append("") + for index in course_details_index_list: + course_detail = row[index] + course_info.append(course_detail) + new_row_first.append(course_detail) + # for index in extra_item_index_dict[1]: + # new_row_first.append(row[index]) + # print(new_row_first) + for extra_item_number, extra_item in enumerate(extra_item_index_list): + if row[extra_item] == "Yes": + # print(extra_item_number) + create_row(row, extra_item_number, extra_item_index_dict, course_info, output_csv_list) + else: + break + # output_csv_list.append(new_row) + # output_csv_list.append(new_row_first) + +# for i in item_details_index_list: +# print(data[0][i]) + + +with open("./output.csv", "w", encoding="utf8", newline='') as output_file: + write = csv.writer(output_file) + write.writerows(output_csv_list) \ No newline at end of file diff --git a/version_1.spec b/version_1.spec new file mode 100644 index 0000000..c21bc14 --- /dev/null +++ b/version_1.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['version_1.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + [], + exclude_binaries=True, + name='version_1', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='version_1') diff --git a/version_2.py b/version_2.py new file mode 100644 index 0000000..58f4828 --- /dev/null +++ b/version_2.py @@ -0,0 +1,112 @@ +import csv +import re +import kivy +kivy.require('2.0.0') +from kivy.app import App +from kivy.uix.label import Label +from kivy.uix.gridlayout import GridLayout +from kivy.uix.textinput import TextInput + +# dirty start to adding a GUI using kivy + +class LoginScreen(GridLayout): + def __init__(self, **kwargs): + super(LoginScreen, self).__init__(**kwargs) + self.cols = 2 + self.add_widget(Label(text='User Name')) + self.username = TextInput(multiline=False) + self.add_widget(self.username) + self.add_widget(Label(text='password')) + self.password = TextInput(password=True, multiline=False) + self.add_widget(self.password) + +class csv_cleaner(App): + + def build(self): + return LoginScreen() + + + def create_row(raw_input_row_list, extra_item_number, extra_item_index_dict, course_info_list, output_csv_list): + # creates new row for extra items + new_row = course_info_list.copy() + for index in extra_item_index_dict[extra_item_number + 1]: + item = raw_input_row_list[index] + new_row.append(item) + output_csv_list.append(new_row) + + with open ('./LWZ_export.csv', encoding="utf8") as input_csv: + input_reader = csv.reader(input_csv, delimiter=',') + data = list(input_reader) + + heading_row = data[0] + + extra_item_index_list = [] + for index, heading in enumerate(data[0]): + if "Another" in heading: + extra_item_index_list.append(index) + + empty_column_headers = ["Status", "File Name", "Notes"] + + course_details_list = ["Length of Reserve", "Full Name", "Course Number", "Course Title"] + + item_details = ["Material", "Author", "Title:", "Page", "Chapter"] + + course_details_index_list = [] + + + for course_detail in course_details_list: + for index, heading in enumerate(data[0]): + if (re.search(course_detail, heading) and (index not in course_details_index_list)): + course_details_index_list.append(index) + break + + extra_item_index_dict = {} + item_details_index_list = [] + + # need to split up item headings by item number + # + for index, heading in enumerate(data[0]): + for item_detail in item_details: + # needs handling for #10 + if (re.search("[1-9]*" + item_detail, heading) and (index not in item_details_index_list) and (index not in course_details_index_list) and ("Journal" not in heading)): + item_details_index_list.append(index) + + + + # split extra item index ref list into chunks by item and add to dictionary + x = 0 + item_number = 1 + for i in range(x,len(item_details_index_list),len(item_details)): + x = i + extra_item_index_dict.update({item_number:item_details_index_list[x:x+5]}) + item_number += 1 + + + output_csv_list = [] + output_csv_list.append(empty_column_headers + course_details_list + item_details) + + # need to create function for new row/item creation. func must take in course row data along with indices of the next item info and/or the item data in a list. row parsing could be separate from new row creation? + for row in data[1:]: + course_info = [] + new_row_first = [] + for item in empty_column_headers: + new_row_first.append("") + course_info.append("") + for index in course_details_index_list: + course_detail = row[index] + course_info.append(course_detail) + new_row_first.append(course_detail) + for extra_item_number, extra_item in enumerate(extra_item_index_list): + if row[extra_item] == "Yes": + create_row(row, extra_item_number, extra_item_index_dict, course_info, output_csv_list) + + else: + break + + with open("./output.csv", "w", encoding="utf8") as output_file: + write = csv.writer(output_file) + write.writerows(output_csv_list) + + +if __name__ == '__main__': + csv_cleaner().run() \ No newline at end of file