DEV Community

Judy
Judy

Posted on

Filter a CSV file and re-arrange it by category #eg60

The CSV file below has 4 columns: idSale (id), Movie (movie name), Genre and Director:

Image description

Use Java to implement a task: filter the file using Director as the argument, group it by Genre, and print data in the order of genre and then movie names. For example, when argument is set as Christopher Nolan, we have the following result:

Image description

Here is SPL script:

Image description

A1: Open the CSV file and filter it by director.

A2: Group the file by Genre and loop to compute one group each time.

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

SPL open source address

Download

Top comments (0)