Aug-10-2019, 07:14 AM
Hi,
I read the excel sheet which has "merged cells", and I want to write to another file retaining original merged cells.
My input excel is below:
I read and write another file, but can not retain merged cells.
row 2 is empty, row4~row5 again empty (but need to be merged with row3 ie, Group2)
How to retain the oroginal merged cells,
I sue below code:
but the output is as below:
I read the excel sheet which has "merged cells", and I want to write to another file retaining original merged cells.
My input excel is below:
1 2 3 4 5 6 7 |
Group Name Date Item Value Group1 VGT 2016 - 06 - 06 Power 0 BHA 2016 - 06 - 07 Voltage 1 Group2 BNA 2016 - 06 - 08 Volume 1 KAL 2016 - 06 - 09 AAA 0 PAR 2016 - 06 - 10 ANM 0 Group3 VGT 2016 - 06 - 11 Power 1 |
row 2 is empty, row4~row5 again empty (but need to be merged with row3 ie, Group2)
1 2 3 4 5 6 7 |
Group Name Date Item Value Group1 VGT 2016 - 06 - 06 00 : 00 : 00 Power 0 empty BHA 2016 - 06 - 07 00 : 00 : 00 Voltage 1 Group2 BNA 2016 - 06 - 08 00 : 00 : 00 Volume 1 empty KAL 2016 - 06 - 09 00 : 00 : 00 AAA 0 empty PAR 2016 - 06 - 10 00 : 00 : 00 ANM 0 Group3 VGT 2016 - 06 - 11 00 : 00 : 00 Power 1 |
I sue below code:
1 2 3 4 |
#%% import pandas as pd infile = 'D:\\mergedinput.xlsx' df = pd.read_excel(infile) |