I want to add a line to the google sheet document with python. But it doesn't work and I always find this error:
Traceback (most recent call last):
File "D:\...\...\...\spreadsheet.py", line 27, in <module>
sheet.add_rows(row,1)
TypeError: add_rows() takes 2 positional arguments but 3 were given
I'm using this code:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("GymBot_database.json", scope)
client = gspread.authorize(creds)
sheet = client.open("GymBot_sheet").sheet1 # Open the spreadsheet
row = sheet.row_values(2) # Get a specific row
insertRow = ["hello", 5, "red", "blue"]
sheet.add_rows(row, 1) # Insert the list as a row at index 1
This code is not really mine I copied it from this link, to do some tests. But in my case it doesn't work and I don't know why.
add_rowstakesinsertRowas input notrow. Check the link again.