Skip to content Skip to sidebar Skip to footer

File Not Found When Using Gspread Import_csv Function In Python

I am using gspread package in python. I try to import a csv into a google spreadsheet but I got an error. My code is as follows: import gspread from oauth2client.service_account im

Solution 1:

I fixed it by sharing the file with the 'client_email' found within the credentials JSON file. Although I did not test this, I also suspect making the spreadsheet Public (anyone on web can see) will fix the issue.

Cheers!


Solution 2:

By going to your sheet and changing sharing options to anyone with the link can edit, fixes it.

Here's the code I used:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ["(some scopes)"]
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)
gc = gspread.service_account("creds.json", scope)
client = gspread.authorize(creds)
sLink = "(link)"
sh = gc.open_by_url(sLink)
sh.share('<example.email.com>', perm_type='user', role='writer')

Solution 3:

Make sure you're using the latest version of gspread. The one that is e.g. bundled with Google Colab is outdated:

!pip install --upgrade gspread

This fixed the error in gs.csv_import for me.


Post a Comment for "File Not Found When Using Gspread Import_csv Function In Python"