Skip to content

CSV reader and writer API that support multiline fields

License

Notifications You must be signed in to change notification settings

etuzon/java-csv-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central GitHub GitHub code size in bytes

CSV API

Java CSV Reader/writer API.

API support multiple lines fields, and custom separators.

Example of multiple line CSV:

header1,"header
2",header3
field1,field2,"field
3"

Code Example:

//Read CSV file
CsvReaderApi csvReader = new CsvReaderApi(CSV_PATH);

List<String> headerList = csvReader.getHeaderList();
List<List<String>> rowsList = csvReader.getRows();

//Overwrite CSV file
CsvWriterApi csvWriter = new CsvWriterApi(CSV_PATH);
csvWriter.setHeaders(headerList);
csvWriter.addRows(rowsList);
//Add new Row that one of the fields is multiline field
//ListUtil.asList is method in Java-Projects-Core
List<String> row = ListUtil.asList("1", "2\n123", "3");
csvWriter.addRow(row);
//save to file
csvWriter.save();