Python excel电子表格比较

Python excel电子表格比较,excel,python-2.7,pandas,Excel,Python 2.7,Pandas,我目前正试图编写一个脚本来比较两个excel文件的内容 清单1的格式如下: Broadcom Drivers and Management Applications [version 17.0.8.2] QLogic Drivers and Management Applications [version 18.00.8.3] NVIDIA 3D Vision Driver 306.97 [version 306.97] Citrix online plug-in (Web) [vers

我目前正试图编写一个脚本来比较两个excel文件的内容

清单1的格式如下:

Broadcom Drivers and Management Applications  [version 17.0.8.2]
QLogic Drivers and Management Applications  [version 18.00.8.3]
NVIDIA 3D Vision Driver 306.97  [version 306.97]
Citrix online plug-in (Web)  [version 12.1.0.30]
Citrix online plug-in (HDX)  [version 12.1.0.30]
Google Update Helper  [version 1.3.32.7]
QfinitiPatches_20131211_Win7 [version 1.0.0.0]
Citrix online plug-in (Web)  [version 12.1.0.30]
Citrix online plug-in (HDX)  [version 12.1.0.30]
Citrix Receiver (HDX Flash Redirection)  [version 14.3.1.1]
Citrix Authentication Manager  [version 7.0.0.8243]
Microsoft Office Access MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office Excel MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office PowerPoint MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office Publisher MUI (English) 2010  [version 14.0.6029.1000]
Mcrosoft Word (All versions)
Microsoft Excel (All versions)
Microsoft Access (All versions)
Microsoft Project (All versions)
Microsoft PowerPoint (All versions)
Microsoft Infopath (All versions)
Microsoft Visio (All versions)
Microsoft SQL Server (All versions)
Microsoft SQL Client (All versions)
Microsoft explorer (version 6+)
Firefox (version 2+)
Oracle Database (All versions)
清单2的格式如下:

Broadcom Drivers and Management Applications  [version 17.0.8.2]
QLogic Drivers and Management Applications  [version 18.00.8.3]
NVIDIA 3D Vision Driver 306.97  [version 306.97]
Citrix online plug-in (Web)  [version 12.1.0.30]
Citrix online plug-in (HDX)  [version 12.1.0.30]
Google Update Helper  [version 1.3.32.7]
QfinitiPatches_20131211_Win7 [version 1.0.0.0]
Citrix online plug-in (Web)  [version 12.1.0.30]
Citrix online plug-in (HDX)  [version 12.1.0.30]
Citrix Receiver (HDX Flash Redirection)  [version 14.3.1.1]
Citrix Authentication Manager  [version 7.0.0.8243]
Microsoft Office Access MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office Excel MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office PowerPoint MUI (English) 2010  [version 14.0.6029.1000]
Microsoft Office Publisher MUI (English) 2010  [version 14.0.6029.1000]
Mcrosoft Word (All versions)
Microsoft Excel (All versions)
Microsoft Access (All versions)
Microsoft Project (All versions)
Microsoft PowerPoint (All versions)
Microsoft Infopath (All versions)
Microsoft Visio (All versions)
Microsoft SQL Server (All versions)
Microsoft SQL Client (All versions)
Microsoft explorer (version 6+)
Firefox (version 2+)
Oracle Database (All versions)
我需要脚本做的是使用列表2作为参考,并在列表1中查找任何匹配的内容。因为这两个列表不完全匹配,所以我需要确保它将拾取部分匹配

例如,在列表1中有Microsoft Office Access MUI(英语)2010[版本14.0.6029.1000],而列表2有Microsoft Access(所有版本),我需要脚本将其作为匹配项,并将其从输出文件中忽略

到目前为止,我有以下几点

import pandas as pd
import numpy as np
df1 = pd.read_excel('/xls comparison project/xl files/Approved Software list.xls', 'Approved Software', parse_cols = 'd', index=False)
df2 = pd.read_excel('/xls comparison project/xl files/Software list.xlsx', 'Sheet1', parse_cols = 'a')
import csv
AS = df1["Software Title"].tolist()
S = df2["Software"].tolist()
我尝试了下面的方法,但这是为了寻找精确的匹配

result = [ x for x in AS if x in S]
我已将两个电子表格的内容以列表格式加载到名为AS和S的变量中。然后,

results = result
resultfile = open("output1.xls",'wb')
wr = csv.writer(resultfile, delimiter=',')
for val in result:
    wr.writerow([val])
resultfile.close()
这将为我提供所需的输出文件

我唯一的问题是比较数据,我已经没有想法了

我在谷歌上搜索了很多地方,虽然我能找到类似的问题,但我无法从它们的内容中找到解决方案。我对python相当陌生,所以我非常感谢您能给我的任何帮助

非常感谢

背风

输出

searching for : Mcrosoft(.*)Word(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)Excel(.*)
                                       Software Title
12  Microsoft Office Excel MUI (English) 2010  [ve...
searching for : Microsoft(.*)Access(.*)
                                       Software Title
11  Microsoft Office Access MUI (English) 2010  [v...
searching for : Microsoft(.*)Project(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)PowerPoint(.*)
                                       Software Title
13  Microsoft Office PowerPoint MUI (English) 2010...
searching for : Microsoft(.*)Infopath(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)Visio(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)SQL(.*)Server(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)SQL(.*)Client(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Microsoft(.*)explorer(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Firefox(.*)
Empty DataFrame
Columns: [Software Title]
Index: []
searching for : Oracle(.*)Database(.*)
Empty DataFrame
Columns: [Software Title]
Index: []