Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Read exel with merged cells and write to another excel
#1
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:

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
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)
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
How to retain the oroginal merged cells,

I sue below code:

#%%
import pandas as pd
infile='D:\\mergedinput.xlsx'
df=pd.read_excel(infile)
but the output is as below:
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how read and write merged cells in excel SriMekala 1 115 Aug-07-2019, 11:27 PM
Last Post: scidam
  Python write result of VAR to excel file wissam1974 8 398 Jul-13-2019, 01:09 PM
Last Post: wissam1974
  Two dataframes merged Ecniv 10 554 Jun-16-2019, 09:10 PM
Last Post: Ecniv
  Python QtableWidget get text of all cells and headers to dataframe Mady 3 1,694 Dec-15-2018, 06:46 PM
Last Post: Axel_Erfurt
  Copy raw data in excel to another new excel file keerthiprashanth 5 603 Oct-20-2018, 10:13 AM
Last Post: volcano63
  Python read Password protected excel and convert to Pandas DataFrame FORTITUDE 2 3,589 Aug-30-2018, 01:08 PM
Last Post: FORTITUDE
  Pandas - Write to Exisitng Excel File - Sorted List dj99 4 2,243 Jul-29-2018, 07:56 AM
Last Post: dj99
  Converting days to years in loop while computing values across grid cells Lightning1800 2 601 May-15-2018, 08:44 PM
Last Post: Lightning1800
  How do I write a line of code into an excel spreadsheet using Python code? Emerogork 2 804 Feb-07-2018, 06:54 PM
Last Post: snippsat
  Write data into existing Excel (xlsx) file with multiple sheets BNB 1 9,040 Jun-01-2017, 04:22 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)