Newer
Older
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('gsheets.json', scope)
gc = gspread.authorize(credentials)
ws = gc.open("vortragsplan-beta").sheet1
rooms = []
times = []
data = []
def cval(cell):
cv = cell.value
if cv:
cv = cv.strip()
return cv
for cell in ws.range(1,1,1,20):
room = cval(cell)
if room:
room = room.strip()
for cell in ws.range(1,1,200,1):
time = cval(cell)
if time:
times.append(cell)
for room in rooms:
roomdata = {'name':room.value}
timeslots = []
for time in times:
timename = time.value
be = timename.split('-')
timeslot = {'time': time.value, 'begin': be[0].strip(), 'end':be[1].strip()}
titel = cval(ws.cell(row=row + 1, col=col))
name = cval(ws.cell(row=row + 2, col=col))
teaser = cval(ws.cell(row=row + 3, col=col))
aufz = cval(ws.cell(row=row + 3, col=col))
if len(lecture) > 0:
lecture['time'] = time.value
lecture['room'] = room.value
timeslot['lecture'] = lecture
timeslots.append(timeslot)
roomdata['times'] = timeslots
with open('../src/src/assets/data/lectures.json', 'w') as outfile: