Retrieve a specified column from a csv file and concatenate its values as a string
We have a standard format csv file.
id,name,mark 20203923380,Lisa Hatfield,62 20200705173,Jessica Johnson,59 20205415333,Adam Harper,41 20203326467,Logan Nolan,77 |
Use Java to do this: Specify a column name, retrieve all values of the column, and concatenate them with the comma. For example, to retrieve mark column and concatenate its values, we have the result: 62,59,41,77.
Write the following SPL code:
=T("data.csv",mark).(#1).concat@c()
T() function parses the csv file as a two-dimensional table, during which multiple column names can be specified. #1 represents the 1st column. concat() function concatenates members of a sequence using a separator; @c option enables using comma as the separator.
Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Source:https://stackoverflow.com/questions/71986830/selecting-a-particular-column-in-a-csv-file-dynamically
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