From 07764b253f35e8248f719d84c858fbe03172446e Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 28 Oct 2022 21:42:03 -0400 Subject: added regenWebAssign --- regenWebAssign.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 regenWebAssign.py diff --git a/regenWebAssign.py b/regenWebAssign.py new file mode 100755 index 0000000..788ecb8 --- /dev/null +++ b/regenWebAssign.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 + +import sys +import pandas as pd +import numpy as np +import os + +# infile = 'wa.csv' +infile = sys.argv[1] + +f = open(infile) +l= f.readlines() +h= l[4] +maxPossible=l[6] +f.close() + +# clean up of headers +h=h.strip() +h = h.replace('"', '') +headers = h.split(',') +headers[0]='FullName' +headers[1]='UserName' +headers[2]='SID' +headers[3]='TotalPcnt' +headers[4]='TotalScore' + +d = pd.read_csv(infile, skiprows=9, header=None, names=headers) +# cleanup +index = d[:][5:] == 'ND' +d[index] = np.nan +index = d[:][5:] == 'NS' +d[index] = np.nan +d['UserName'].replace('@wm$', '', regex=True, inplace=True) + +d.to_csv('WebAssign.csv') + +# now import to sqlite3 + +os.popen('rm -f WebAssign.db') +p = os.popen('printf ".mode csv\n.import \"WebAssign.csv\" export_table\n.q" | sqlite3 WebAssign.db') +p.close() + -- cgit v1.2.3