Read specified columns from a csv file

Here is a standard format csv file:

Region,Country,City,Year,Month,Day,Support Consultant

Europe,Sweden,Stockholm,2014,12,31,B. Good

Europe,Sweden,Stockholm,2014,11,21,B. Good

North Africa/Middle East,Saudi Arabia,Riyadh,2014,12,9,E. Gipt

Use Java to do this: Use the specified multiple column numbers as parameters to retrieve the corresponding columns from the csv file, and parse them as a two-dimensional table. For example, when the parameters are "#1,#3,#5", we have the following result:

Region

City

Month

Europe

Stockholm

12

Europe

Stockholm

11

North Africa/Middle East

Riyadh

12

Write the following SPL code:

=T(\"d:\\result.csv\":T(\"d:\\data.csv\",${arg_cols}))

T()parses a file or writes data to a file; it supports specifying multiple column numbers. ${} treats a string as an expression to execute.

Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.

Source:https://stackoverflow.com/questions/70586145/how-to-read-a-specific-column-of-a-row-from-a-csv-file-in-java