-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_csv.py
38 lines (36 loc) · 1012 Bytes
/
create_csv.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
import csv
from uwstyle.excel import Excel
import excelloader
def writecsv(data):
print("> Create CSV")
header = [
"Start Date",
"Start Time",
"End Date",
"End Time",
"Subject",
"Location",
"Description"
]
items = [header]
for d in data:
item = []
item.append(d["day"].strftime("%Y/%m/%d"))
item.append(d["time"].start_datetime.strftime("%H:%M"))
item.append(d["day"].strftime("%Y/%m/%d"))
item.append(d["time"].end_datetime.strftime("%H:%M"))
item.append(d["name"].encode('cp932', "ignore").decode('cp932'))
item.append("ふらっとステーション・とつか")
item.append(d["category"].encode('cp932', "ignore").decode('cp932'))
items.append(item)
with open("import.csv", "w") as f:
writer = csv.writer(f, lineterminator="\n")
for item in items:
writer.writerow(item)
print("> Finished")
if __name__ == "__main__":
excel = Excel()
data = excelloader.load(excel)
if data is None:
exit
writecsv(data)