DEV Community

Judy
Judy

Posted on

Clear duplicate lines and lines having missing values from a csv file #eg24

In the csv file below, some lines have null values, some have NaN values, and there are duplicate lines.

Image description
Use Java to do this: Delete lines containing null values or NaN values, and remove the duplicate lines. Below is the expected result:

Image description
Write the SPL script:

Image description
A1: Parse the csv file as a two-dimensional table.

A2: Convert records of the table to a sequence and perform intersection with [null,NaN] to get records that are not their common members.

A3: Group A2’s records, and get the first record from each group while keeping the original order.

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

Source:https://stackoverflow.com/questions/70806307/how-to-remove-row-which-contains-blank-cell-from-csv-file-in-java

Top comments (1)

Collapse
 
esproc_spl profile image
Judy

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