【发布时间】:2017-07-03 05:09:58
【问题描述】:
我需要一些关于 python 的帮助。基本上我有 2 个文件(对于这个例子,文件 1 和文件 2)。 File1 里面有几张纸,file2 只是一张纸。因此,在 file2 中进行了一些工作之后,现在我有了我需要的 DataFrame。我需要将此 DataFrame 粘贴到 file1 的一个特定工作表中。
File1
A B C D E F G
<data> <data> <data> <data> <formula> <formula> <formula>
<data> <data> <data> <data> <formula> <formula> <formula>
<data> <data> <data> <data> <formula> <formula> <formula>
<data> <data> <data> <data> <formula> <formula> <formula>
<data> <data> <data> <data> <formula> <formula> <formula>
<data> <data> <data> <data> <formula> <formula> <formula>
File2
A B C D
<Newdata> <Newdata> <Newdata> <Newdata>
<Newdata> <Newdata> <Newdata> <Newdata>
<Newdata> <Newdata> <Newdata> <Newdata>
<Newdata> <Newdata> <Newdata> <Newdata>
<Newdata> <Newdata> <Newdata> <Newdata>
<Newdata> <Newdata> <Newdata> <Newdata>
So now i need to update the file one with the new Data.
File1
A B C D E F G
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
<Newdata> <Newdata> <Newdata> <Newdata> <formula> <formula> <formula>
因此,E、F 和 G 列有一些公式,这些公式由 A、B、C、D 列中的数据更新。
我尝试了不同的选项来做到这一点。连接两个文件并显示我尝试的列,加载两个文件并使用新信息创建一个新文件...主要问题是在文件 1 中我有几张表,我需要保留,因为列 E、F和 G(有公式的那个),将更新其他工作表。
所以,如果有人帮我解决这个问题,请。谢谢,我将不胜感激
【问题讨论】:
-
使用
openpyxl。它将能够处理.xlsx文件中所需的所有内容。如果两个文件都使用xlsx,请告诉我,我会尽我所能提供帮助。刚刚注意到它是一个xlsb文件。不知道那些:( -
@Sid .xlsb 是一个很大的 xlsx,我可以在两个文件中使用 xlsx,你能帮我吗
-
嗯..我似乎无法将数据保留在 E、F 和 G 行中。试图找出原因。如果你愿意,我可以将代码发布到现在。