Python Forum
Merging excel worksheets with balnk rows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merging excel worksheets with balnk rows
#1
Hi,

There is a task where I have to merge multiple excel spread sheets. The column number do not start from the first column and it can lie & start from any where or row in the spreadsheet.
There are blank rows in between data points which needs to be copied.

045401 641378-2019 2019079763 186851 2019-10-24 2019-10-27 EUR 5,919.58
045401 641379-2019 2019079764 190110 2019-10-24 2019-10-27 EUR 64.56



212716 00247743-2019 201910323 124320 2019-10-01 2019-10-01 EUR 61,001.44
212716 00248118-2019 201910680 128698 2019-10-09 2019-10-09 EUR 58,671.33

I donot want these rows to be copied to my destination or target excel file. I am using openpyxl and have trying to avoid these rows by using 'None' to identify blankrows but this logic is not working.
Code--
for row in range(a,ws1.max_row):      
         colnum=3
         for j in range(2,9):
              if ws1.cell(a,1).value != None:    
                  c=ws1.cell(row,j)                 
                  ws2.cell(rownumber,colnum).value=c.value
                  colnum=colnum+1
              else:
                  break;
         rownumber=rownumber+1
Reply
#2
ANy help on this will be appreciated
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  merging rows arvin 2 796 Dec-24-2022, 04:56 AM
Last Post: arvin
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,802 Dec-12-2022, 08:22 PM
Last Post: jh67
  Deleting rows based on cell value in Excel azizrasul 11 2,479 Oct-19-2022, 02:38 AM
Last Post: azizrasul
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,602 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  Merging spreadsheets with the same columns and extracting rows with matching entries johnbernard 3 8,387 Aug-19-2021, 03:08 PM
Last Post: johnbernard
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,082 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 6,962 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  Merging Excel Files JezMim 1 1,859 Sep-06-2020, 08:56 PM
Last Post: bowlofred
  Excel tables and move rows jdos 6 4,454 Jul-02-2020, 05:52 AM
Last Post: jdos
  Reading specific rows from CVS to Excel DavidTheGrockle 3 2,615 Nov-06-2019, 04:49 PM
Last Post: DavidTheGrockle

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020