diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-10-23 23:39:29 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-10-23 23:39:29 -0400 |
commit | e3ff0c17fe50ef42303f49257b683f6e057ca5c1 (patch) | |
tree | 9a14a9d0ae35660ec53af0d0edcae6172d425ed6 /regenWebAssign.py | |
parent | ec3f2c041e135a7ced9dc5b654e364f0bab0765e (diff) | |
download | GradeBook-e3ff0c17fe50ef42303f49257b683f6e057ca5c1.tar.gz GradeBook-e3ff0c17fe50ef42303f49257b683f6e057ca5c1.zip |
black formatter
Diffstat (limited to 'regenWebAssign.py')
-rwxr-xr-x | regenWebAssign.py | 63 |
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() - |