-1

Yesterday I was still able to create a google sheet files using gspread into a specific folder using this code:

ss = gc.create(fileName,"my folder destination")

But today, this code yields an error.

Here is my full code:

from google.colab import auth
auth.authenticate_user()

import pandas as pd

import gspread
from google.auth import default
creds, _ = default()

gc = gspread.authorize(creds)

wb = gc.open('file name')
ws = wb.worksheet('sheet name')

# get_all_values gives a list of rows.
rows = ws.get_all_values()
df = pd.DataFrame.from_records(rows[1:],columns=rows[0])

modisseries = df["column name"]
uniquemodis = modisseries.drop_duplicates().tolist()

def createSpreadsheet(columName):
  ndf = df[df["Modis"] == Columname]
  nlist = [ndf.columns.tolist()] + ndf.to_numpy().tolist()
  ss = gc.create(columnName,"Folder_id")
  nws = ss.sheet1
  nws.update_title(columnName)
  nws.update("A1",nlist,value_input_option="USER_ENTERED")

for modis in uniquemodis:
  createSpreadsheet(modis)

And here is the error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-5c297289782b> in <module>()
     30 
     31 for column_value in uniquecolumn:
---> 32   createSpreadsheet(column_value)

<ipython-input-1-5c297289782b> in createSpreadsheet(column_value)
     24   nlist = [ndf.columns.tolist()] + ndf.to_numpy().tolist()
     25 
---> 26   ss = gc.create(column_value,"folder_id")
     27   nws = ss.sheet1
     28   nws.update_title(column_value)

TypeError: create() takes 2 positional arguments but 3 were given

1 Answers1

0

Hi which version of gspread do you use ? The parameter folder_id has been introduced in version 3.5.0

From the error message you get it seems you have an old version and it does not handle the new parameter folder_id.

You can check the version you are currently using by using: print(gspread.__version__)

If this is bellow version 3.5.0 then run the following command: python3 -m pip install -U gspread

Lavigne958
  • 442
  • 5
  • 12