如何读取 Google 电子表格中空行之后的行?
我正在使用 gdata-python-client 从 Google 读取数据电子表格。我的读取行的代码如下:
import gdata.speadsheet.text_db
gd_client = gdata.spreadsheet.text_db.DatabaseClient(
username=setting['account_name'],
password=setting['account_pass'])
xls_db = gd_client.GetDatabases(spreadsheet_key=setting['spreadsheet_id'])
first_sheet = xls_db[0].GetTables()[0]
entries = first_sheet.GetRecords(1, 200)
假设电子表格有 160 行,第 12th 行为空。当我尝试使用上述代码读取所有 160 行时,它只读取前 11 行(也就是说,直到它获取空的第 12 行)。如果电子表格没有任何空行,代码将读取所有 160 行。
当我尝试从空行读取下一行时,它什么也不返回。例如:
entries = first_sheet.GetRecords(50, 55) # entries is None
如何从包含空行的 Google 电子表格中读取所有行。
任何帮助将不胜感激。
I'm using gdata-python-client to read data from a Google spreadsheet. My code for reading rows is as follows:
import gdata.speadsheet.text_db
gd_client = gdata.spreadsheet.text_db.DatabaseClient(
username=setting['account_name'],
password=setting['account_pass'])
xls_db = gd_client.GetDatabases(spreadsheet_key=setting['spreadsheet_id'])
first_sheet = xls_db[0].GetTables()[0]
entries = first_sheet.GetRecords(1, 200)
Let's say, the spreadsheet has 160 rows and the 12th row is empty. When I try to read all 160 rows using the above code, it only reads the first 11 rows (that is, until it gets the empty 12th row). If the spreadsheet doesn't have any empty rows, the code reads all 160 rows.
When I try to read the next rows from the empty row, it returns nothing. for example:
entries = first_sheet.GetRecords(50, 55) # entries is None
How can I read all the rows from a Google spreadsheet which contains empty rows.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,可能已经太晚了,我刚刚发现这个问题。 :)
所以,这里是 Google Docs 电子表格 API 的文档:
http:// /code.google.com/apis/spreadsheets/data/3.0/developers_guide.html
答案如下:
顺便说一句,我认为当提要结束时,没有太多行;你徒劳地看到它。 :)
干杯
Sorry, may be it's too late, I just found this question. :)
So, here is the documentation of Google Docs spreadsheet API:
http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html
and there is the answer:
BTW, I think when the feed ends, there aren't much rows; you see it in vain. :)
Cheers
如果电子表格之间有空行,您可以使用
CellFeed
。You can use
CellFeed
in case your spreadsheet has empty rows in between.