gspread icon indicating copy to clipboard operation
gspread copied to clipboard

Same value for all merged cells

Open arredond opened this issue 6 years ago • 4 comments

Currently, when you read from a spreadsheet that has merged (combined) cells, the value is only kept for the first of the individual cells that compose the merged cell.

It would be great to have a flag, when reading a spreadsheet wih get_all_records(), to duplicate that initial value for all individual cells that compose the merged cell.

arredond avatar Oct 14 '19 14:10 arredond

I do this in https://github.com/aiguofer/gspread-pandas/blob/2d2d5a1049d15f0f6e8c19c990c7ca1de3fec2d1/gspread_pandas/spread.py#L785

I'd be happy to try to create a PR when I have some time

aiguofer avatar Jan 30 '20 22:01 aiguofer

I am concerned about the detail: duplicate the initial value. I merged cells in a spreadsheet and exported the sheet as csv file to have it in a way that looks similar to a list of lists with values.

I have the first 2 celles [A1, A2] are merged together with a value of 'XXX', the output as csv file contains the following line for those 2 celles: 'XXX,' which means the value of A2 is empty.

This is the behavior that google provides and I believe we should follow it, as people may use csv files before and now use gspread and expect a similar result.

lavigne958 avatar Apr 23 '20 19:04 lavigne958

@lavigne958 that's a nice concern to have but the feature I'm proposing is just to have a parameter that controls this. I'm not saying what the default (to duplicate values or not) should be.

IMHO, what you're describing is a legacy behavior that, yes, some users might expect, but may be very unintuitive for others (such as myself). Having the option to choose is always nice :)

arredond avatar Apr 23 '20 21:04 arredond

My apologies I did not get the "option" / "parameter" part,I ended up on this page from the PR and no the other-way around.

I do think this option is useful then.

lavigne958 avatar Apr 24 '20 10:04 lavigne958