Browse Source

copying files to public repo

master
Alan 3 years ago
commit
9abf46002b
  1. 2
      .gitignore
  2. 6
      README.md
  3. BIN
      course_reserves_cleanup.zip
  4. BIN
      dist/version_1/VCRUNTIME140.dll
  5. BIN
      dist/version_1/_asyncio.pyd
  6. BIN
      dist/version_1/_bz2.pyd
  7. BIN
      dist/version_1/_ctypes.pyd
  8. BIN
      dist/version_1/_decimal.pyd
  9. BIN
      dist/version_1/_hashlib.pyd
  10. BIN
      dist/version_1/_lzma.pyd
  11. BIN
      dist/version_1/_multiprocessing.pyd
  12. BIN
      dist/version_1/_overlapped.pyd
  13. BIN
      dist/version_1/_queue.pyd
  14. BIN
      dist/version_1/_socket.pyd
  15. BIN
      dist/version_1/_ssl.pyd
  16. BIN
      dist/version_1/base_library.zip
  17. BIN
      dist/version_1/libcrypto-1_1.dll
  18. BIN
      dist/version_1/libffi-7.dll
  19. BIN
      dist/version_1/libssl-1_1.dll
  20. BIN
      dist/version_1/pyexpat.pyd
  21. BIN
      dist/version_1/python39.dll
  22. BIN
      dist/version_1/select.pyd
  23. BIN
      dist/version_1/unicodedata.pyd
  24. BIN
      dist/version_1/version_1.exe
  25. 103
      version_1.py
  26. 44
      version_1.spec
  27. 112
      version_2.py

2
.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
__pycache__
build

6
README.md

@ -0,0 +1,6 @@ @@ -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.

BIN
course_reserves_cleanup.zip

Binary file not shown.

BIN
dist/version_1/VCRUNTIME140.dll vendored

Binary file not shown.

BIN
dist/version_1/_asyncio.pyd vendored

Binary file not shown.

BIN
dist/version_1/_bz2.pyd vendored

Binary file not shown.

BIN
dist/version_1/_ctypes.pyd vendored

Binary file not shown.

BIN
dist/version_1/_decimal.pyd vendored

Binary file not shown.

BIN
dist/version_1/_hashlib.pyd vendored

Binary file not shown.

BIN
dist/version_1/_lzma.pyd vendored

Binary file not shown.

BIN
dist/version_1/_multiprocessing.pyd vendored

Binary file not shown.

BIN
dist/version_1/_overlapped.pyd vendored

Binary file not shown.

BIN
dist/version_1/_queue.pyd vendored

Binary file not shown.

BIN
dist/version_1/_socket.pyd vendored

Binary file not shown.

BIN
dist/version_1/_ssl.pyd vendored

Binary file not shown.

BIN
dist/version_1/base_library.zip vendored

Binary file not shown.

BIN
dist/version_1/libcrypto-1_1.dll vendored

Binary file not shown.

BIN
dist/version_1/libffi-7.dll vendored

Binary file not shown.

BIN
dist/version_1/libssl-1_1.dll vendored

Binary file not shown.

BIN
dist/version_1/pyexpat.pyd vendored

Binary file not shown.

BIN
dist/version_1/python39.dll vendored

Binary file not shown.

BIN
dist/version_1/select.pyd vendored

Binary file not shown.

BIN
dist/version_1/unicodedata.pyd vendored

Binary file not shown.

BIN
dist/version_1/version_1.exe vendored

Binary file not shown.

103
version_1.py

@ -0,0 +1,103 @@ @@ -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)

44
version_1.spec

@ -0,0 +1,44 @@ @@ -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')

112
version_2.py

@ -0,0 +1,112 @@ @@ -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()
Loading…
Cancel
Save