简体   繁体   English

使用 Python 将数据写入现有 Excel 表的最快方法是什么?

[英]What's the fastest way to write data to an existing Excel sheet using Python?

I'm working on a Windows 10 machine (win32, Python 3.8.2).我正在使用 Windows 10 机器(win32、Python 3.8.2)。 I'm using pandas to read in two excel files as dataframes, then using Openpyxl to write data to an existing Excel file (that has data and formulas already in the sheet).我正在使用 pandas 读取两个 excel 文件作为数据帧,然后使用 Openpyxl 将数据写入现有的 Excel 文件(已经在表格中)。 The approach I'm using now with Openpyxl works, but is quite time-consuming.我现在对 Openpyxl 使用的方法有效,但非常耗时。 I'm wondering if there's another, faster approach to writing data to an existing Excel sheet?我想知道是否有另一种更快的方法将数据写入现有的 Excel 表? I feel like this could possibly be done by appending my dataframe(s) to the existing Excel sheet, but I've read online that the sheet I am writing to would have all of its data erased before my data is written to it.我觉得这可以通过将我的数据帧附加到现有的 Excel 表来完成,但我在网上读到我正在写入的表会在我的数据写入之前删除所有数据。 Here are some of the resources I've read about this issue on:以下是我读过的有关此问题的一些资源:

I would pull it in with pd.read_csv(), do manipulations then write with df.to_csv().我会用 pd.read_csv() 把它拉进去,做操作然后用 df.to_csv() 写。 Do you need to keep it in the excel format?需要保持excel格式吗? I tend to find that this is not worth it.我倾向于发现这是不值得的。

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

相关问题 在 python 中使用 openpyxl 将数据写入 excel 工作表是否有更快的方法? - Is there a faster way to write data to an excel sheet using openpyxl in python? 想要读取一个文件并使用 python 写入现有的 excel 表 - Want to read an a file and write to existing excel sheet using python Python Excel 在现有工作表中写入 DataFrame - Python Excel write a DataFrame in an existing sheet 使用 python 将 SQL 输出数据更新到相应工作表中的现有 Excel - Update SQL output data into Existing Excel in respective sheet using python 使用OpenCV在Python中迭代CvMat的最快方法是什么? - What's the fastest way to iterate over a CvMat in Python using OpenCV? 在python中扩展URL的最快方法是什么 - What's the fastest way to expand url in python 在 Python 中解析 arguments 的最快方法是什么? - What's the fastest way to parse arguments in Python? 使用openpyxl将数据写入现有的Excel工作表 - Writing data to an existing excel sheet using openpyxl 如何通过使用 pandas 在工作表中覆盖来在现有 excel 中写入 json 数据? - How can I write json data in an existing excel by overwriting in a sheet using pandas? 打开现有 Excel 文件、清除现有工作表并将数据框写入该工作表的最佳方法 - Best way to open existing excel file, clear an existing sheet and write dataframe to that sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM