Skip to content
Snippets Groups Projects
Commit 18b6ebb2 authored by wonko's avatar wonko
Browse files

vortraege aus google sheet direct in json

parent 09dddcbc
No related branches found
No related tags found
No related merge requests found
from openpyxl import load_workbook
import gspread
import json
wb = load_workbook(filename='vortragsplan-17.5..xlsx')
ws = wb['Tabelle1']
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 = []
......@@ -16,19 +25,17 @@ def cval(cell):
cv = cv.strip()
return cv
for rows in ws.iter_cols(min_col=2, min_row=1, max_row=1):
for cell in rows:
room = cval(cell)
for cell in ws.range(1,1,1,20):
room = cval(cell)
if room:
room = room.strip()
if room:
room = room.strip()
if room:
rooms.append(cell)
rooms.append(cell)
for rows in ws.iter_rows(min_col=1, min_row=1, max_row=ws.max_row + 1, max_col=1):
for cell in rows:
time = cval(cell)
if time:
times.append(cell)
for cell in ws.range(1,1,200,1):
time = cval(cell)
if time:
times.append(cell)
for room in rooms:
......@@ -40,21 +47,21 @@ for room in rooms:
timeslot = {'time': time.value, 'begin': be[0].strip(), 'end':be[1].strip()}
lecture = {}
col = room.col_idx
col = room.col
row = time.row
fs = cval(ws.cell(row=row, column=col))
fs = cval(ws.cell(row=row, col=col))
if fs:
lecture['fs'] = fs
titel = cval(ws.cell(row=row + 1, column=col))
titel = cval(ws.cell(row=row + 1, col=col))
if titel:
lecture['titel'] = titel
name = cval(ws.cell(row=row + 2, column=col))
name = cval(ws.cell(row=row + 2, col=col))
if name:
lecture['name'] = name
teaser = cval(ws.cell(row=row + 3, column=col))
teaser = cval(ws.cell(row=row + 3, col=col))
if teaser:
lecture['teaser'] = teaser
aufz = cval(ws.cell(row=row + 3, column=col))
aufz = cval(ws.cell(row=row + 3, col=col))
if aufz:
lecture['aufz'] = aufz
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment