Search code examples
google-sheetsgoogle-apigoogle-sheets-apigoogle-api-python-clientgoogle-python-api

google spreadsheet api return empty last cell - python -


if spreadsheet is

    A | B | C
 1  1 |
 2  1 | 2 | 
 3  1 | 2 | 3
 4  1 |   | 3

this function from api google spreadsheet

self.service.spreadsheets().values().get(spreadsheetId=self.sheet,
                                                    range='{0}!{1}'.format(wstitle, a1range),
                                                    majorDimension=major_dimension=DIMENSIONS['ROWS'],
                                                    valueRenderOption=VALUE_RENDER_OPTION['FORMATTED'],
                                                    dateTimeRenderOption=DATETIME_RENDER_OPTION['FORMATTED']).execute()

return

[1],[1,2],[1,2,3],[1,'',3]

is possible to return empty cells? e.g.

 [1,'',''],[1,2,''],[1,2,3],[1,'',3]

Solution

  • Sheetsv4 ignores empty cells and does not say that the cell's value is null.

    It says in the docs that empty rows and columns are omitted:

    Empty trailing rows and columns are omitted.

    I would suggest that you assign a dummy data/letter/symbol that represents your empty cells so that when you encounter this data/letter/symbol when you do a check using the "GET" method, you can interpret it as empty cell.

    Related SO thread.