简体   繁体   English

使用python熊猫将现有的Excel工作表与新的数据框追加到新的数据框,而无需加载旧的

[英]Append existing excel sheet with new dataframe using python pandas without loading the old one

This is an old question, however no one wrote a solution for without loading the excel file. 这是一个古老的问题,但是没有人为不加载excel文件编写了解决方案。 Assuming the excel file is too huge, this will be inefficient to load the existing file and save on it. 假设excel文件太大,则加载现有文件并保存在该文件上效率不高。 Instead is there any method to append, like for ordinary files? 相反,有没有其他方法可以附加,例如普通文件?

df is the dataframe I would like to append df是我要附加的数据框

df.to_excel(folder+"file.xlsx", header=False, index=False)

However file.xlsx exists and there is another df with the same headers. 但是存在file.xlsx,并且还有另一个具有相同标题的df。

How can I append df to existing file.xlsx, without loading file.xlsx? 如何在不加载file.xlsx的情况下将df附加到现有的file.xlsx?

I do not know about any append features in Openpyxl. 我不了解Openpyxl中的任何附加功能。 Openpyxl has however a writeonlymode wb = Workbook(write_only=True) 但是Openpyxl具有writeonlymode wb = Workbook(write_only=True)

I would try to save (and append) the dataframe as a feather binary file, then just delete and create a new workbook with write_only mode. 我会尝试将数据帧保存(并追加)为羽化二进制文件,然后删除并使用write_only模式创建一个新的工作簿。

This should be much faster than loading and appending the Excel file, but it will depend on what type and how much data there is. 这应该比加载和附加Excel文件快得多,但是这将取决于类型和数量。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "使用 python pandas 将现有的 excel 表附加到新的数据框" - Append existing excel sheet with new dataframe using python pandas 无法将Pandas Dataframe附加到现有的Excel工作表 - unable to append pandas Dataframe to existing excel sheet 将新的Pandas DataFrame附加到旧的,而没有对列名称进行排序的情况 - Append new Pandas DataFrame to an old one without column names sorted Python将Excel表格添加到Pandas-DataFrame中 - Python Append an excel sheet into Pandas-DataFrame 尝试将 append 现有 dataframe 的总和转换为新的 excel 表 - Trying to append the sum of an existing dataframe into a new excel sheet 如何将数据框附加到现有的Excel工作表? - How to append a dataframe to existing excel sheet? 如何在不使用pandas更改文件中的现有数据的情况下将新列附加到Excel文件? - How to append a new column to an Excel file without changing the existing data on the file using pandas? 如何在python中使用panda在现有excel表中追加列 - how to append columns in existing excel sheet using panda in python 如何 append 到 pandas dataframe 到 ZBF57C906FA7D2BB66D96372E4158 表 - How to append a pandas dataframe to an excel sheet 使用熊猫,如何只从 Excel 工作簿中读取一张工作表而不加载任何其他工作表? - Using pandas, how to only read one sheet from Excel workbook without loading any of the other sheets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM