使用来自输出的数据子集创建新的电子表格

时间:2019-07-09 22:03:53

标签: python excel pandas data-extraction

您好,我是一名刚毕业的研究生实践工程师,我的编码背景包括matlab。

我正在尝试将一个混乱的输出excel文件重组到另一个表中,以便进一步输入数据。 Excel主文件具有大量行,并具有重复的15-20行格式。我只想在相邻单元格匹配字符串时才提取特定单元格中的值。这是我到目前为止的内容:

import csv
A=[]
B=[]
with open(r'filepath\book1.csv', newline='') as infh:
    reader = csv.reader(infh)
    for row in reader:
        i=1
        if row[0] == 'DL reaction':

              A.append(max(row[1],row[2]))
        if row[0] == 'Max +LL reaction':
            B.append(max(row[1],row[2]))

print(A),print(B)

从这里,我想将这两个向量提取到单个矩阵中,然后导出到表中。另外,如果有解决上述问题的更干净的方法,我将很高兴学习。谢谢

Attached here is an example of the data set and the resulting table to the right which I am trying to create using python.

0 个答案:

没有答案