aboutsummaryrefslogtreecommitdiff
path: root/regenWebAssign.py
diff options
context:
space:
mode:
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()
-