Java, fill each row having a null value in a csv file with values in the directly previous row #eg32

In the csv file below, Number column has some null values.

Task: Use Java to modify the file. The rule is like this: When a Number value is null, modify values of the current row as those of the directly previous row and save result as a new csv file…


This content originally appeared on DEV Community and was authored by Judy

In the csv file below, Number column has some null values.

Image description
Task: Use Java to modify the file. The rule is like this: When a Number value is null, modify values of the current row as those of the directly previous row and save result as a new csv file.

Image description
Write the following SPL statement:

=T(""result.csv"":T(""data.csv"").(~=if(Number,~,~[-1])))

T()function reads data from or writes data to a csv file. ~ is the current record, and ~[-1] represents the directly previous record.

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

SPL open source address


This content originally appeared on DEV Community and was authored by Judy


Print Share Comment Cite Upload Translate Updates
APA

Judy | Sciencx (2024-08-27T07:58:50+00:00) Java, fill each row having a null value in a csv file with values in the directly previous row #eg32. Retrieved from https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/

MLA
" » Java, fill each row having a null value in a csv file with values in the directly previous row #eg32." Judy | Sciencx - Tuesday August 27, 2024, https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/
HARVARD
Judy | Sciencx Tuesday August 27, 2024 » Java, fill each row having a null value in a csv file with values in the directly previous row #eg32., viewed ,<https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/>
VANCOUVER
Judy | Sciencx - » Java, fill each row having a null value in a csv file with values in the directly previous row #eg32. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/
CHICAGO
" » Java, fill each row having a null value in a csv file with values in the directly previous row #eg32." Judy | Sciencx - Accessed . https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/
IEEE
" » Java, fill each row having a null value in a csv file with values in the directly previous row #eg32." Judy | Sciencx [Online]. Available: https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/. [Accessed: ]
rf:citation
» Java, fill each row having a null value in a csv file with values in the directly previous row #eg32 | Judy | Sciencx | https://www.scien.cx/2024/08/27/java-fill-each-row-having-a-null-value-in-a-csv-file-with-values-in-the-directly-previous-row-eg32/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.