diff --git a/toggl2sheets.py b/toggl2sheets.py index 3d4e2f0..87033e2 100644 --- a/toggl2sheets.py +++ b/toggl2sheets.py @@ -70,14 +70,14 @@ today = datetime.datetime.now().date() - datetime.timedelta(days=1) def append_hours(worksheet: Worksheet, data: List[List[str]]): - # add a calculated hours * wage cell to all rows - # start at number 2 to skip header - d = [[*x, f"=C{i}*D{i}"] for i, x in enumerate(data, start=2)] column = worksheet.get_col(1) # get last non-empty row last_row = next(filter(lambda x: not x[1], enumerate(column)))[0] + # add a calculated hours * wage cell to all rows + d = [[*x, f"=C{i}*D{i}"] for i, x in enumerate(data, start=last_row + 1)] + worksheet.insert_rows(last_row, len(d), d) # inserting rows changes the top sums