Filter a csv file and generate a new file
Here is a csv file separated by semicolon and without column headers. The 2nd column is date.
10;06.07.2022;This is test;
08;01.07.2020;This is test;
15;06.07.2021;This is test;
09;06.07.2021;This is test;
Task: Perform conditional filtering on this file according to the date and write result to a new file in the same format. When the condition is specified as “date is 06.07.2022 or earlier than it”, we have the following result:
10;06.07.2022;This is test;
Here is the SPL code:
>file(\"result.csv\").export(file(\"test.csv\").import(;,\";\").select(#2>=?);\";\")
export()function writes a two-dimensional table to a text file. import() function parses a text file. select() function performs the conditional filtering. Remember to set the SPL date format as MM.dd.yyyy.
Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Source: https://stackoverflow.com/questions/72884533/manipulate-csv-file-using-groovy-and-java
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