-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwmaker.py
35 lines (27 loc) · 1.25 KB
/
twmaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
#
# This quick script converts the student roster output of Powerschool to something TypingWeb will import.
#
# Python 2 compatibility
from __future__ import print_function, division, absolute_import, unicode_literals
import csv
def main():
print("Hi guys")
outfile = open('per8tw.csv', 'w', newline='')
studentwriter = csv.writer(outfile, delimiter=' ',quotechar='"', quoting=csv.QUOTE_MINIMAL)
studentwriter.writerow(["Username,","Password,","Firstname,","Lastname,","Email"])
with open('per8.csv', newline='') as csvfile:
studentreader = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in studentreader:
username = "joebob"
password = row[1]
# later, fix quotes for spaces in first and last names.
firstname = row[0].split(',')[1].replace(' ','')
lastname = row[0].split(',')[0].replace(' ','')
# create the real username
username = firstname.lower().rstrip()[:4] + lastname.lower().rstrip()[:4]
print(','.join([username, password, firstname, lastname]))
studentwriter.writerow([','.join([username, password, firstname, lastname])])
outfile.close()
if __name__ == '__main__':
main()