举例
有 Excel 文件 Book1.xlsx,部分数据如下所示:
| id | name | item | amount |
| 1001 | alice | eye | 60 |
| 1001 | alice | eye | -60 |
| 1002 | tom | nose | 30 |
| 1003 | jerry | stomach | 70 |
| 1003 | jerry | stomach | -70 |
| 1003 | jerry | hand | 50 |
| 1004 | bob | arm | 100 |
| 1005 | jack | leg | 25 |
| 1005 | jack | leg | -25 |
需要把符合 id 一致、item 一致,amount 值正负抵消的行数删掉,结果如下:
| id | name | item | amount |
| 1002 | tom | nose | 30 |
| 1003 | jerry | hand | 50 |
| 1004 | bob | arm | 100 |
编写SPL脚本:
| A | |
| 1 | =file("Book1.xlsx").xlsimport@t() |
| 2 | =A1.group(id,item).select(~.sum(amount)!=0).conj() |
| 3 | =file("result.xls").xlsexport@t(A2) |
A1 读取 excel 文件内容
A2 按 id,item 分组,筛选出组内 amount 和不为 0 的数据,合并
A3 结果导出至 result.xlsx
686

被折叠的 条评论
为什么被折叠?



