Get the whole group where at least one member meets the specified condition
The csv file below consists of student names and student scores:
Name,Score A,17 A,19 A,22 B,17 B,15 C,22 D,19 E,22 E,22 |
Task: Use Java to find all records of students who has at least one score that is equivalent to or greater than 20.
Name |
Score |
A |
17 |
A |
19 |
A |
22 |
C |
22 |
E |
22 |
E |
22 |
Write the following SPL statement:
=T(""d:\\data.csv"").group(Name).select(~.count(Score>=20)>0).conj()
T()function parses the csv file as a two-dimensional table. group() function groups data while retaining records in each group. ~ is the current group; count() function gets the number of records meeting the specified condition.
Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Source:https://stackoverflow.com/questions/75799714/spark-java-group-by-and-filter-on-custom-condition
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL