googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.76k stars 2.41k forks source link

Empty cells parameter for spreadsheet read method #856

Open hahahannes opened 4 years ago

hahahannes commented 4 years ago

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

busunkim96 commented 4 years ago

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!

hahahannes commented 4 years ago

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.

busunkim96 commented 4 years ago

Ah, it looks like I was reading too quickly.

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

hahahannes commented 4 years ago

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 commented 4 years ago

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.

laurikoobas commented 4 years ago

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.

vchudnov-g commented 1 year ago

@hahahannes @laurikoobas Is this issue still occurring?

rbren commented 1 year ago

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

tominh commented 5 months ago

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