google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

Empty cells parameter for spreadsheet read method

Open hahahannes opened this issue 4 years ago • 9 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe. I am trying to read data from my google spreadsheet by using:

service = build('sheets', 'v4', credentials=creds)
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=spreadsheet_id,range='sheet', majorDimension='COLUMNS').execute()

which returns the data but ignores empty cells as written in the doc[1]. The problem is that it destroys the structure of my table because fields with the same index in the list dont belong together.

Describe the solution you'd like It would be nice to include the empty cells as empty strings like in the plain HTTP API response. Maybe as a parameter for the values().get method.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. Additional context Thanks for reading and considering my idea!

[1] https://googleapis.github.io/google-api-python-client/docs/dyn/sheets_v4.spreadsheets.values.html#get

hahahannes avatar Apr 08 '20 11:04 hahahannes

Hi @hahahannes,

This Python client is a wrapper around the REST API itself. https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get

It sounds like this is a feature request for the API. Please file a feature request here.

Thanks!

busunkim96 avatar Apr 08 '20 16:04 busunkim96

Hi @busunkim96, thanks a lot for your fast answer! I am just a bit confused because the API itself already returns empty strings for empty cells. So I thought, they have to be removed in the wrapper but I guess, I missunderstand something there.

hahahannes avatar Apr 08 '20 22:04 hahahannes

Ah, it looks like I was reading too quickly.

The HTTP response returns empty strings, but the library skips those cells?

busunkim96 avatar Apr 08 '20 22:04 busunkim96

Exactly, if I understood correctly. It is also written in the client doc https://googleapis.github.io/google-api-python-client/docs/dyn/sheets_v4.spreadsheets.values.html#get that empty cells are omitted.

hahahannes avatar Apr 09 '20 08:04 hahahannes

Hi, just wanted to quickly ask, if this is considered as a valid feature request. If so, I would be glad to help out, but couldnt find the spreadsheet section in the code so far.

hahahannes avatar May 11 '20 10:05 hahahannes

I just ran into this as well - same thing seems to be happening on the row level. For example if I import a range of "A:E" and columns B and C are sometimes empty then the resulting arrays are length 3 or 4, with no way to tell which column they came from.

laurikoobas avatar Jun 01 '20 12:06 laurikoobas

@hahahannes @laurikoobas Is this issue still occurring?

vchudnov-g avatar Jan 31 '23 22:01 vchudnov-g

@vchudnov-g I'm seeing this issue as well

rbren avatar Feb 14 '23 22:02 rbren

I just ran into this as well - same thing seems to be happening on the row level. For example if I import a range of "A:E" and columns B and C are sometimes empty then the resulting arrays are length 3 or 4, with no way to tell which column they came from.

It still an issue with google sheet api v4

tominh avatar Jun 04 '24 06:06 tominh