diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-10-28 21:42:03 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-10-28 21:42:03 -0400 |
commit | 07764b253f35e8248f719d84c858fbe03172446e (patch) | |
tree | 4d5dbda72a1a2fe1f097bd8eaaf19587b844b724 | |
parent | 703f8733d7c9301adce496f67d81657c26ef2084 (diff) | |
download | GradeBook-07764b253f35e8248f719d84c858fbe03172446e.tar.gz GradeBook-07764b253f35e8248f719d84c858fbe03172446e.zip |
added regenWebAssign
-rwxr-xr-x | regenWebAssign.py | 42 |
1 files changed, 42 insertions, 0 deletions
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() + |