Reorganizing CSV With Carriage Returns In Java Using SPL
Reorganize csv file with Java using SPL script: import data.csv as 2D table, handle carriage returns & quotes, modify table with run() function.
Here is a csv file. Its 3rd column contains strings of a special format – they are enclosed by double quotation marks and some occupy multiple rows (which means they contain carriage return). Task: Use Java to reorganize the csv file as a standard two-dimensional table. Write the following SPL statement: =file(""data.csv"").import@tcoq().run(description=replace(description,""\n"","""")) import() function parses the csv file as a two dimensional table; @t option enables importing the 1st row as column names, @c option enables using commas as the separator, @o option handles the unescaped carr...