aboutsummaryrefslogtreecommitdiff
path: root/regenWebAssign.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-11-11 09:29:18 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-11-11 09:29:18 -0500
commitfb11e4ced498d2ee0b6c66cfdb4d8259f9698715 (patch)
tree12145a1ae039d4ae1eabeb2ca58b109ae70f0404 /regenWebAssign.py
parentd1892ef5c9a08049a3be73e0e9903c605bfedcd9 (diff)
parente3ff0c17fe50ef42303f49257b683f6e057ca5c1 (diff)
downloadGradeBook-master.tar.gz
GradeBook-master.zip
Merge branch 'master' of qo.physics.wm.edu:evmik/GradeBookHEADmaster
Diffstat (limited to 'regenWebAssign.py')
-rwxr-xr-xregenWebAssign.py63
1 files changed, 35 insertions, 28 deletions
diff --git a/regenWebAssign.py b/regenWebAssign.py
index 007dc2d..18e9841 100755
--- a/regenWebAssign.py
+++ b/regenWebAssign.py
@@ -9,44 +9,51 @@ import os
infile = sys.argv[1]
f = open(infile)
-l= f.readlines()
-h= l[4]
-maxPossible=l[6]
+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=[0,1,2,3,4,5,7,8], header=None, names=headers)
-d.loc[0, 'FullName']='MaxScore'
-d.loc[0, 'UserName']='MaxScore'
+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=[0, 1, 2, 3, 4, 5, 7, 8], header=None, names=headers)
+d.loc[0, "FullName"] = "MaxScore"
+d.loc[0, "UserName"] = "MaxScore"
# cleanup
c = d.columns
-c=c.drop(['FullName', 'UserName', 'SID'])
-index = d[c] == 'ND'
+c = c.drop(["FullName", "UserName", "SID"])
+index = d[c] == "ND"
d[index] = np.nan
-index = d[c] == 'NS'
+index = d[c] == "NS"
d[index] = np.nan
-d['UserName'].replace('@wm$', '', regex=True, inplace=True)
-d['UserName'].replace('@email.wm.edu$', '@wm.edu', regex=True, inplace=True)
+d["UserName"].replace("@wm$", "", regex=True, inplace=True)
+d["UserName"].replace("@email.wm.edu$", "@wm.edu", regex=True, inplace=True)
# hand tuned fixes
-d['UserName'].replace('phanng@hotmail.com@tj.va$', 'kphan@wm.edu', regex=True, inplace=True)
-d['UserName'].replace('chipkd2001@gmail.com$', 'ckdangerio@wm.edu', regex=True, inplace=True)
-d['UserName'].replace('eliasarivera@live.com@schs.va$', 'earivera@wm.edu', regex=True, inplace=True)
-
-d.to_csv('WebAssign.csv', index=False)
+d["UserName"].replace(
+ "phanng@hotmail.com@tj.va$", "kphan@wm.edu", regex=True, inplace=True
+)
+d["UserName"].replace(
+ "chipkd2001@gmail.com$", "ckdangerio@wm.edu", regex=True, inplace=True
+)
+d["UserName"].replace(
+ "eliasarivera@live.com@schs.va$", "earivera@wm.edu", regex=True, inplace=True
+)
+
+d.to_csv("WebAssign.csv", index=False)
# 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')
+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()
-