Home > Java > javaTutorial > Read specified columns from a csv file #eg44

Read specified columns from a csv file #eg44

Patricia Arquette
Release: 2024-09-19 18:16:03
Original
1146 people have browsed it

Here is a standard format csv file:

Read specified columns from a csv file #eg44
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:

Read specified columns from a csv file #eg44
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.

This is one of the problems on StackOverflow. You can click on it to see that the conventional solution is quite complicated, but the SPL approach is really simple and efficient.

SPL open source address

The above is the detailed content of Read specified columns from a csv file #eg44. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template