[英]How do I fix "Error tokenizing data" error when reading Google Spreadsheet into pandas DataFrame?
so I have been reading google sheets into DataFrames.所以我一直在将谷歌表格读入数据帧。 Older sheets are working perfectly with this methodology but any new google sheets keep giving me the same error.
较旧的工作表可以完美地使用这种方法,但任何新的谷歌工作表都会给我同样的错误。
Error tokenizing data.
标记化数据时出错。 C error: Expected 1 fields in line 6, saw 2
C 错误:第 6 行需要 1 个字段,但看到了 2 个
The way that has been working and continues to work on most of the google sheets I read from is the following:在我阅读的大多数谷歌表格上一直有效并继续有效的方式如下:
starting_url = 'https://docs.google.com/spreadsheets/d/{Sheet ID}/edit#gid=0
csv_url = starting_url.replace('edit#gid=0','export?format=csv&gid=0')
Now the new url is:现在新的 url 是:
csv_url = 'https://docs.google.com/spreadsheets/d/{Sheet ID}/export?format=csv&gid=0'
I then try to read it in like any other csv file:然后我尝试像读取任何其他 csv 文件一样读取它:
df = pd.read_csv(csv_url)
This continues to work on multiple google sheets that I pull data from regularly.这继续适用于我定期从中提取数据的多个谷歌表格。 But for some reason this has not been working on any new google sheets that get added.
但由于某种原因,这在添加的任何新谷歌表格上都不起作用。
I get the same error on every new sheet I try to read.我尝试阅读的每张新纸上都会出现同样的错误。 Whether there are 2 rows or 1000 rows It always gives me the same error:
无论是 2 行还是 1000 行它总是给我同样的错误:
Error tokenizing data.
标记化数据时出错。 C error: Expected 1 fields in line 6, saw 2
C 错误:第 6 行需要 1 个字段,但看到了 2 个
Is this because of some update to google sheets itself?这是因为谷歌表格本身的一些更新吗? If so can anyone recommend another method that doesn't require a ton of effort?
如果是这样,谁能推荐另一种不需要大量努力的方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.