Skip to content
Advertisement

Is there a change for reading the published CSV from Google Sheets in Google Colab?

I have been using a file from Google sheets, published as CSV, and reading it with Pandas, to make the dataframe, but today stopped working here it is the error output:

/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in read(self, nrows)

2155 def read(self, nrows=None): 2156 try: -> 2157 data = self._reader.read(nrows) 2158 except StopIteration: 2159 if self._first_chunk:

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()

pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error()

ParserError: Error tokenizing data. C error: Expected 1 fields in line 6, saw 2

If I use the same sheet, but reading it directly from a CSV file from Google Drive, there’s no problem, and it’s working perfectly.

If I use:

df= pd.read_csv(url,sep=’t’, lineterminator=’r’)

There’s no errror in reading the data, but I got this, when trying to read the df:

Error reading the DF

Hopefully is something similar, to this question? Thanks in advance for your attention!

Advertisement

Answer

This is a bug

See this link: https://issuetracker.google.com/173534863

Go give it a ☆ to let Google know that this affects you.

The workaround as you have said, is to change the permissions of the file to be viewable by “Anyone with link”. Previously this was not necessary.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement