[英]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.