【问题】
I have a long list made up of text like this
Email: example@example.com
Language Spoken: Sample
Points: 52600
Lifetime points: 100000
Country: US
Number: 1234
Gender: Male
Status: Activated
=============================================
I need a way of filtering this list so that only students with higher than 52600 points gets shown. I wanted to know how this could be done in a bat file or some similar solution? I have tried excel but no luck.
【回答】
将文本每8行分为一组,过滤出这样的组:第3个成员按冒号拆分,拆分出的第2部分大于52600。最后将这些组的组内成员按顺序纵向拼在一起。上述算法涉及分组运算、有序运算、结构化运算,适合用SPL:
| A | |
| 1 | =file("d:\\data.txt").import@i() |
| 2 | =A1.group((#-1)\8) |
| 3 | =A2.select(int(substr(~(3),"Points:"))>52600) |
| 4 | =A3.conj() |
A1:读取文本文件data.txt中的内容,并将每一行作为一个序列成员,最后返回成序列。
A2:对序列A1进行分组,每8个分成一组。
A3:先获取序列A2的每组中第3个成员里Points:后边的内容,再转化为int型,最后选出大于52600的分组。
A4:将A3每组的组内成员按顺序纵向拼在一起。
本文介绍如何使用SPL语言在批处理文件中过滤一个包含学生成绩的列表,只显示分数超过52600的学生信息。适合处理大量数据的高效筛选方法。
686

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



