-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto_achieve.py
51 lines (39 loc) · 1.64 KB
/
to_achieve.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 19 20:15:21 2016
@author: a
Simple tool to merge two spreadsheets to create an "import" roster for
Achieve 3000 folks. They use it to create their rosters with our
existing account names and passwords.
"""
import csv
import dataset
DISTRICT = 'Hilo-Waiakea Complex Area'
SCHOOL = 'Waiakea Intermediate School'
PWFILE = 'pw-8th.csv' # saved from the reference pw spreadsheet
ROSTER = 'per6.csv' # from the PDF roster report in eSIS. Name, Student number
OUTFILE= 'period6-roster.csv' # here is what you want to send to Achieve
GRADE = '8'
db = dataset.connect('sqlite:///:memory:')
table = db['students']
with open(PWFILE) as pwfile:
reader = csv.DictReader(pwfile)
for row in reader:
table.insert(row)
with open(OUTFILE, 'w', newline='') as outfile:
writer = csv.writer(outfile)
# write header
writer.writerow(['District','School','Last Name','First Name','Student ID'\
,'Grade','KB Login Name','KB Password','Type'])
with open(ROSTER) as rosterfile:
reader = csv.reader(rosterfile)
for row in reader:
lastname, firstname = [name.strip() for name in row[0].split(',')]
student_id = row[1]
print(firstname,lastname)
res = db.query('SELECT [Email Address],[Password] FROM students \
WHERE[First Name]="' + firstname +'" AND [Last Name]="' + lastname +'"')
for row in res:
writer.writerow([DISTRICT,SCHOOL, lastname, firstname,
student_id, GRADE,
row['Email Address'].split('@')[0], row['Password'],'Student'])