Excel:比较两个csv文件,并从相应的列中隔离行数据

时间:2019-07-03 08:58:26

标签: excel csv excel-formula comparator

我有两个CSV文件,其中2.5万行包含一个数据,而9000行包含一个名称,我需要从第一个文件中获取数据。 有人告诉我,使用excel会很容易,但是我似乎找不到类似的问题。

我已经尝试过比较工具,但是它们并不能帮助我隔离需要的东西。 使用此示例

主文件:

Name;email;displayname
Bbob;Bbob@mail.com;Bob bob
Mmartha;Martha@mail.com;Mmartha
Cclaire;Cclaire@mail.com;cclair

名称文件:

Name
Mmartha
Cclaire

比较后我需要得到什么:

Name;email;displayname
Mmartha;Martha@mail.com;Mmartha
Cclaire;Cclaire@mail.com;cclair`

因此,对于第二个csv中的名称,我必须从主csv文件中获取整行。 现在,我可以使用记事本比较作为示例,但是考虑到我的需要,在25000行上,这需要大量的体力劳动。我认为有人面对类似问题也是有办法的。 我似乎现在找不到解决方案,所以我在这里。

1 个答案:

答案 0 :(得分:0)

在此之前,请以荷兰语屏幕截图为借口,我不确定PowerQuery中的英语术语,但是您应该可以按照以下步骤进行操作。

使用PowerQuery:

  • 启动PowerQuery

enter image description here

  • 同时加载源CSV1和CSV2

enter image description here

  • 加入查询作为新人

enter image description here

  • 同时选择第1列,然后选择Inner选项

enter image description here

  • 结果应如下所示:

enter image description here

  • 使用第一行作为标题:

enter image description here

  • 删除第4列,关闭并加载值

enter image description here