'Appending one row at a time from Dataframe to Google Sheet with Python
I have this code for writing data to google sheets with Python. Is it possible to append one row at a time, instead of inserting the entire data frame at once?
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=os.environ['GOOGLE_SHEET_ID'],
range=range,
valueRenderOption='FORMATTED_VALUE').execute()
new_row = df.applymap(str).values.tolist()
result = sheet.values().append(
spreadsheetId=os.environ['GOOGLE_SHEET_ID'],
range=range,
valueInputOption='USER_ENTERED',
body=dict(
majorDimension='ROWS',
values=new_row)
).execute()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
