Read specified columns from a csv file #eg44

Here is a standard format csv file:

图片[1]-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:

图片[2]-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

原文链接:Read specified columns from a csv file #eg44

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
Only they who fulfill their duties in everyday matters will fulfill them on great occasions.
只有在日常生活中尽责的人才会在重大时刻尽责
评论 抢沙发

请登录后发表评论

    暂无评论内容