-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgsheet2yaml.py
52 lines (43 loc) · 1.41 KB
/
gsheet2yaml.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
52
'''
csv table header
Academic Conference Name,Location (Alpha),"Dates
(Grey = past; Green = March; Yellow = April; Blue = May)",Notes,Announcement Link,^
Academic Conference Name
Location (Alpha)
"Dates
(Grey = past; Green = March; Yellow = April; Blue = May)"
Notes
Announcement Link
'''
'''
item={}
item['name']=row['Academic Conference Name']
item['date']=row["Dates\n(Grey = past; Green = March; Yellow = April; Blue = May)"]
item['location']=row['Location (Alpha)']
item['notes']=row['Notes']
item['link']=row['Announcement Link']
'''
import csv
import yaml
with open('_data/conferences.yml','w') as ymlfile:
with open('conferences.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
#print('-----------------------')
#print(row)
item={}
for k,v in dict(row).items():
if k is None :
del row[k]
else:
item[k[:5]]=v
#print(k)
keys=['Acade','Annou','Dates','Locat','Notes']
newitem={}
for k in keys:
newitem[k]=item[k].replace('\n','')
#print(yaml.dump(newitem))
#item[Location (Alpha)]
#print('+++++++++++++++++++++++')
ymlfile.write(yaml.dump([newitem]))
#print(' -----------------------')