|
6 | 6 |
|
7 | 7 | PRINT_TABULATE = False
|
8 | 8 | SHOW_VIS = False
|
| 9 | +SAVE_SCHOOL_CSV = True |
| 10 | +SAVE_SCHOOL_HTML = True |
9 | 11 |
|
10 | 12 | # load clustered schedule (make sure you go make that first in google sheets)
|
11 |
| -with open("data/student schedule utc clustered.csv", encoding="utf-8") as file: |
| 13 | +filename = input("Enter clustered schedule filename (default: student schedule utc clustered.csv): ") or "student schedule utc clustered.csv" |
| 14 | +with open("data/{}".format(filename), encoding="utf-8") as file: |
12 | 15 | data = [
|
13 | 16 | {k: v for k, v in row.items()}
|
14 | 17 | for row in csv.DictReader(file, skipinitialspace=True)
|
|
28 | 31 | plt.show()
|
29 | 32 |
|
30 | 33 | # load original RSVPs and make map keyed by email
|
31 |
| -with open("data/HS - Master RSVPs.csv", encoding="utf-8") as rsvpFile: |
| 34 | +filename = input("Enter contacts filename (default: contacts.csv): ") or "contacts.csv" |
| 35 | +with open("data/{}".format(filename), encoding="utf-8") as rsvpFile: |
32 | 36 | rsvps = [
|
33 | 37 | {k: v for k, v in row.items()}
|
34 | 38 | for row in csv.DictReader(rsvpFile, skipinitialspace=True)
|
|
103 | 107 | for s in schoolOrder
|
104 | 108 | ]
|
105 | 109 |
|
106 |
| -"""# save utc school schedule |
107 |
| -with open( |
108 |
| - "data/FINAL school schedule utc.csv", "w", encoding="utf-8", newline="" |
109 |
| -) as schoolScheduleCSVFile: |
110 |
| - csvFields = ["School", "Start Time"] |
111 |
| - writer = csv.DictWriter(schoolScheduleCSVFile, fieldnames=csvFields) |
112 |
| - writer.writeheader() |
113 |
| - writer.writerows(schoolOrder) |
114 |
| - print("\n--> Saved FINAL school schedule utc CSV!")""" |
| 110 | +if SAVE_SCHOOL_CSV: |
| 111 | + # save utc school schedule |
| 112 | + filename = input("Enter school schedule CSV filename (default: school schedule utc.csv): ") or "school schedule utc.csv" |
| 113 | + with open( |
| 114 | + "data/{}".format(filename), "w", encoding="utf-8", newline="" |
| 115 | + ) as schoolScheduleCSVFile: |
| 116 | + csvFields = ["School", "Start Time"] |
| 117 | + writer = csv.DictWriter(schoolScheduleCSVFile, fieldnames=csvFields) |
| 118 | + writer.writeheader() |
| 119 | + writer.writerows(schoolOrder) |
| 120 | + print("\n--> Saved FINAL school schedule utc CSV!") |
115 | 121 |
|
116 |
| -# use tabulate to save html school schedule |
117 |
| -with open("data/school-schedule.html", "w", encoding="utf-8") as schoolScheduleHTMLFile: |
118 |
| - # schoolScheduleHTMLFile.write(tabulate(schoolOrder, headers="keys", tablefmt="html")) |
119 |
| - print(schoolOrder) |
120 |
| - print("\n--> Saved FINAL school schedule utc HTML!") |
| 122 | +if SAVE_SCHOOL_HTML: |
| 123 | + # use tabulate to save html school schedule |
| 124 | + filename = input("Enter school schedule HTML filename (default: school-schedule.html): ") or "school-schedule.html" |
| 125 | + with open("data/{}".format(filename), "w", encoding="utf-8") as schoolScheduleHTMLFile: |
| 126 | + schoolScheduleHTMLFile.write(tabulate(schoolOrder, headers="keys", tablefmt="html")) |
| 127 | + print(schoolOrder) |
| 128 | + print("\n--> Saved FINAL school schedule utc HTML!") |
121 | 129 |
|
122 | 130 | # save final dataset
|
123 | 131 | finalData = []
|
|
130 | 138 | student["Approx Time Zone"] = item["Time Zone"]
|
131 | 139 | finalData.append(student)
|
132 | 140 |
|
| 141 | +filename = input("Enter student schedule filename (default: student schedule utc.csv): ") or "student schedule utc.csv" |
133 | 142 | with open(
|
134 |
| - "data/FINAL student schedule utc.csv", "w", encoding="utf-8", newline="" |
| 143 | + "data/{}".format(filename), "w", encoding="utf-8", newline="" |
135 | 144 | ) as studentScheduleFile:
|
136 | 145 | csvFields = list(finalData[0].keys())
|
137 | 146 | writer = csv.DictWriter(studentScheduleFile, fieldnames=csvFields)
|
|
0 commit comments