行式数据求交并差

这篇博客通过两个示例详细介绍了如何使用SPL脚本对Excel数据进行行式求交、并、差的操作。在例1中,针对特定列(team列)进行了操作;在例2中,进一步展示了对整行数据进行相同操作的方法。通过这些例子,读者可以学习到如何高效地处理和合并数据。
摘要由CSDN通过智能技术生成

举例

例1:对关键列求交并差

有Excel文件Book1.xlsx,数据如下所示:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey
4KaylaHaileyJenniferAustinMatthew

有Excel文件Book2.xlsx,数据如下所示:

teammember1member2member3member4member5
10DanielKaylaSarahLuisRyan
15AbigailHaileyAntonyMadisonTimothy
11HaleyStephanieJustinJosephBryan
13TimothyJosephHaileyKatherineLauren
12RyanDavidIsabellaJuliaJose
9JuliaHaleyElizabethJuliaAlyssa
14JoseChristianClaireDylanJose
8ChristianLaurenJustinAustinChloe

两份数据按team列求交、并、差。

编写SPL脚本:

A
1=file("Book1.xlsx").xlsimport@t()
2=file("Book2.xlsx").xlsimport@t()
3=[A1,A2].merge@ou(team)
4=[A1,A2].merge@oi(team)
5=[A1,A2].merge@od(team)

A1   读取Excel数据

A2   读取Excel数据

A3  按team列并,结果如下:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey
4KaylaHaileyJenniferAustinMatthew
15AbigailHaileyAntonyMadisonTimothy
11HaleyStephanieJustinJosephBryan
13TimothyJosephHaileyKatherineLauren
12RyanDavidIsabellaJuliaJose
14JoseChristianClaireDylanJose

A4  按team列交,结果如下:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey

A5  按team列差,结果如下:

teammember1member2member3member4member5
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
4KaylaHaileyJenniferAustinMatthew

例2:对整行求交并差

有Excel文件Book1.xlsx,数据如下所示:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey
4KaylaHaileyJenniferAustinMatthew

有Excel文件Book2.xlsx,数据如下所示:

teammember1member2member3member4member5
10DanielKaylaSarahLuisRyan
15AbigailHaileyAntonyMadisonTimothy
11HaleyStephanieJustinJosephBryan
13TimothyJosephHaileyKatherineLauren
12RyanDavidIsabellaJuliaJose
9JuliaHaleyElizabethJuliaAlyssa
14JoseChristianClaireDylanJose
8ChristianLaurenJustinAustinChloe

两份数据按整行求交、并、差。

编写SPL脚本:

A
1=file("Book1.xlsx").xlsimport@t()
2=file("Book2.xlsx").xlsimport@t()
3=[A1,A2].merge@ou()
4=[A1,A2].merge@oi()
5=[A1,A2].merge@od()

A1   读取Excel数据

A2   读取Excel数据

A3  按整行并,结果如下:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey
4KaylaHaileyJenniferAustinMatthew
10DanielKaylaSarahLuisRyan
15AbigailHaileyAntonyMadisonTimothy
11HaleyStephanieJustinJosephBryan
13TimothyJosephHaileyKatherineLauren
12RyanDavidIsabellaJuliaJose
9JuliaHaleyElizabethJuliaAlyssa
14JoseChristianClaireDylanJose
8ChristianLaurenJustinAustinChloe

A4  按整行交,因为两份数据没有相同记录,结果为空。

A5  按整行差,结果如下:

teammember1member2member3member4member5
9TaylorStephanieStephanieDavidAmanda
7IanAngelaBrookeStevenTimothy
5NicholasMichaelMadelineAntonyLogan
3SophiaJacobAndrewAlexisBrianna
6ChristopherAlyssaBenjaminThomasCourtney
1HannahIsabellaAbigailLoganMary
2BenjaminStephanieJenniferJacobJose
10KatherineJonathanKaylaIsabellaLuis
8DanielJustinDylanAmandaHailey
4KaylaHaileyJenniferAustinMatthew

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值