[英]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....我有两个不同的 Excel 文件一个是我需要更新的主文件,第二个包含我需要复制和粘贴的数据所以....
This is my master excel file I want to update looks like this这是我要更新的主 excel 文件看起来像这样
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
而这个 excel 包含我需要将其复制到master file
的列数据,因为它们是三张称为GSM_CDDData
、 UMTS_CDDData
和LTE_CDDData
的工作表,并且这三张工作表包含相同的列名,我需要复制它的数据并将它们添加到Master Excel
,因为列名是CELLNAME
and this excel looks like这个 excel 看起来像
After Copying this data,I want to paste them in the Master Excel
in column called CELL
复制此数据后,我想将它们粘贴到名为CELL
的列中的Master Excel
So any Ideas how to do that?.....那么任何想法如何做到这一点?......
as I know the supported library pandas
and openpyxl
据我所知,支持的库pandas
和openpyxl
If you want to copy and paste the data itself, you might consider use of the pywin32 package (if you have Windows)如果您想复制和粘贴数据本身,您可以考虑使用 pywin32 package(如果您有 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如果您不想使用 pywin32,您可以使用导入各个列
pd.read_excel()
and append or concatenate the objects.和 append 或连接对象。 From there you can save the new dataframe using to_excel.从那里您可以使用 to_excel 保存新的 dataframe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.