1

Im parsing data for study purposes so I create scraping module, data frame module and now I need to finish "upload to Google Drive data frame as Google Sheet" but stuck on this error.

from fileinput import filename
import gspread

credentials = {...
}
gc = gspread.oauth_from_dict(credentials)

tag = bs_search
sh = gc.open(filename, 'kid')
worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
worksheet.update([df.columns.values.tolist()] + df.values.tolist())
worksheet.update_cell(1, 4, 'Send to')
worksheet.update_cell(1, 5, 'Not Send to')
worksheet.update_cell(1, 6, 'Instagram')

Output:

   13 gc = gspread.oauth_from_dict(credentials)
     15 tag = bs_search
---> 16 sh = gc.open(filename, 'kid')
     17 worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
     18 worksheet.update([df.columns.values.tolist()] + df.values.tolist())

AttributeError: 'tuple' object has no attribute 'open'
MasterMind
  • 97
  • 7
  • See the [docs here](https://docs.gspread.org/en/latest/oauth2.html#for-end-users-using-oauth-client-id) with example code showing a tuple returned by the function: `gc, authorized_user = gspread.oauth_from_dict(credentials)`. – Mark Oct 09 '22 at 00:45

1 Answers1

1

If you look at the docs for the gspread project, they have an example for this function:

gc, authorized_user = gspread.oauth_from_dict(credentials)

Notice there are two values before the equals.

More information: https://docs.gspread.org/en/latest/oauth2.html

Nick ODell
  • 15,465
  • 3
  • 32
  • 66
  • Look like I just forget to add ```authorised_user``` Going to check right now! – MasterMind Oct 09 '22 at 01:14
  • Can I ask you for a tip how to download ```authorised_user``` from Google Dev Console? I simply don't see it (Previosly I downloaded client_secrets.json and it work ok but sorry I really can't understand where is ```authorised_user``` because on my Oauth screen are only credentials... ) – MasterMind Oct 09 '22 at 01:29