I want to export the local excel data to google sheets. I got all APIs and requirements. Now, I'm trying to that python script in this link https://blog.coupler.io/python-to-google-sheets/#:~:text=append()-,Python%20script%20to%20export%20Excel%20to%20Google%20Sheets,-Already%20have%20an
def export_excel_to_sheets():
spreadsheet_id = '1JCEHwIa4ZzwAiKGmAnWGfbjeVCH_tWZF6MkIU0zICwM'
excel_data_df = pandas.read_excel('sample-excel.xlsx', sheet_name='Sheet1', skiprows = range(1, 62), engine='openpyxl')
excel_data_df['Date'] = excel_data_df['Date'].astype(str)
excel_data_df['Unnamed: 0'] = ''
body = {
'values': excel_data_df.values.tolist()
}
spreadsheet_service.spreadsheets().values().append(
spreadsheetId=spreadsheet_id, body=body, valueInputOption='USER_ENTERED', range='Sheet1').execute()
print('{0} cells appended.'.format(result \
.get('updates') \
.get('updatedCells')))
export_excel_to_sheets()
I have 70 rows of data and I want to export them to Google Sheets. I don't want to "skip" any rows with "skiprows = range(1,62)" so I delete or decrease the value. When I delete this code, the script gets a HTTP400 error.
excel_data_df = pandas.read_excel('example.xlsx', sheet_name='Sheet1', skiprows = range(1, 62), engine='openpyxl')
When I delete "skiprows" code, get a HttpError 400.
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1VIWNRrBF3E9KQo_nT7ZXvT4qQYWymITAFLx2rDEGSPw/values/Sheet1:append?valueInputOption=USER_ENTERED&alt=json returned "Invalid JSON payload received. Unexpected token.
api/v1/users/home", NaN, "{ 'Content-Typ
^">
I want to export all data to Google Sheets without a problem. What is your suggestion to do that? Thank you.
Invalid JSON payload received. Unexpected token., can you provide the sample XLSX file? Because, when I tested your showing script, even whenskiprows = range(1, 62)is removed using a sample XLSX file, no error occurs. I apologize for this.