简体   繁体   English

如何将具有相同列名的列数据的多个工作表复制并粘贴到另一个 excel 文件

[英]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 文件看起来像这样

Excel Master 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_CDDDataUMTS_CDDDataLTE_CDDData的工作表,并且这三张工作表包含相同的列名,我需要复制它的数据并将它们添加到Master Excel ,因为列名是CELLNAME

and this excel looks like这个 excel 看起来像

Source资源

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据我所知,支持的库pandasopenpyxl

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.

相关问题 如何使用python的xlsx从一个excel文件中复制多列并根据用户需要将它们粘贴到另一个excel文件中? - How to copy multiple column from one excel file and paste them according to user's need in another excel file using python's xlsx? (Python)如何将列复制并粘贴到另一个表? - (Python) How to Copy and Paste a column to another table? 如何在 Python 中将整列数据(行数不固定)复制到同一个 Excel 文件中的新列? - How can I copy an entire column of data (the number of rows are not fixed) to a new column in the same excel file, in Python? Python for Excel:虽然 A 列中的值相同,但获取剩余的行数据并将粘贴复制到新工作表 - Python for Excel: While value in column A is the same, take remaining row data and copy paste to new worksheet 如何使用 Python 将数据从一个 Excel 工作表复制到同一工作簿的另一工作表? - How to copy data from One Excel sheet to another sheet for same Workbook Using Python? 如何将一个CSV文件中的多行和一列复制到另一个CSV Excel中? - How to copy multiple rows and one column from one CSV file to another CSV Excel? 熊猫:复制一行的值并将其粘贴到另一列中的多行上方 - Pandas: Copy a value of a row and paste it to multiple rows above in another column 如何使用python将数据从excel复制并粘贴到另一个excel - How to copy and paste data from excel to another excel using python 将列复制到Python中的另一个工作表 - Copy column to another sheet in Python 我想相对于列对表格中 excel 文件中存在的数据进行排序。 (excel文件有多张) - I want to sort data present in excel file in sheet with respect to column. (The excel file has multiple sheets)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM