DEV Community

Judy
Judy

Posted on

3 1 1 1 1

Retrieve multiple columns from a csv file to generate a new file #eg23

I have a standard format csv file:

Image description
I need to use Java to do this: Take column names as the parameter to retrieve multiple columns and save them as a new file. For example, when the parameter is "ID,Name,Gender", the expected new file is as follows:

Image description
Write the following SPL code:

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

T()function parses a file or writes data of a file to a new one, where we can specify column names; ${} 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/69819686/how-to-extract-csv-columns-with-the-specific-header-names-and-output-to-a-new-fi

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (1)

Collapse
 
esproc_spl profile image
Judy

SPL open source address:github.com/SPLWare/esProc/stargazers

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay