def save_row(self, csv_type, data_type, data):
if data_type == 'entry':
if csv_type == 'run_logger':
tab = 'Runs'
last_column = 'Y'
total = 'AA1'
elif csv_type == 'arena_logger':
tab = 'Arena'
last_column = 'P'
total = 'R1'
elif csv_type == 'summon_logger':
tab = 'Summon'
last_column = 'F'
total = 'H1'
elif csv_type == 'raid_logger':
tab = 'Raid'
last_column = 'K'
total = 'M1'
elif csv_type == 'worldboss_logger':
tab = 'World Boss'
last_column = 'AA'
total = 'AC1'
elif csv_type == 'toa_logger':
tab = 'ToA'
last_column = 'O'
total = 'Q1'
elif csv_type == 'guild_battle_logger':
tab = 'Guild'
last_column = 'S'
total = 'U1'
names, row = data
key_file = self.config['google_key']
sheet_name = self.config['sheet_name']
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(key_file, scope)
gc = gspread.authorize(credentials)
wks = gc.open(sheet_name).worksheet(tab)
line = int(wks.acell(total).value) + 2
cl = wks.range('A%s:%s%s' % (line, last_column, line))
for (i, name) in enumerate(names):
if name in row:
cl[i].value = row[name]
wks.update_cells(cl)
评论列表
文章目录