简体   繁体   中英

How to copy and paste multiple sheet for column's data with the same column name to another excel file

I have two different Excel files One is the master I need to update and the second one contains the data I need to copy and paste So....

This is my master excel file I want to update looks like this

Excel Master

and this excel which contains column data I need to copy it to the master file , as thee's are three sheets called GSM_CDDData , UMTS_CDDData , and LTE_CDDData and the three sheets contains the same column name which I need to copy it's data and add them to the Master Excel , as the columns name is CELLNAME

and this excel looks like

Source

After Copying this data,I want to paste them in the Master Excel in column called CELL

So any Ideas how to do that?.....

as I know the supported library pandas and openpyxl

If you want to copy and paste the data itself, you might consider use of the pywin32 package (if you have Windows)

from win32com.client import Dispatch
xl = Dispatch("Excel.Application")
wb1 = xl.Workbooks.Open(Filename=file_name)
ws1 = wb1.Worksheets(sheet_1)
ws2 = wb1.Worksheets(sheet_2)
ws1.Columns(index_number).Copy(ws2.Columns(index_number))

If you don't want to use pywin32, you might just import the various columns using

pd.read_excel()

and append or concatenate the objects. From there you can save the new dataframe using to_excel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM