Questions tagged [jcsv]

jCSV is a very easy to use csv library for Java.

jCSV is a very easy to use csv library for Java. With just a few lines of Code you can parse any csv file.

Reader reader = new FileReader("data.csv");
CSVReader<String[]> csvParser = CSVReaderBuilder.newDefaultReader(reader);
List<String[]> data = csvParser.readAll();

jCSV also provides mechanisms to bind the csv file directly to java objects.

Reader reader = new FileReader("persons.csv");

CSVReader<Person> csvPersonReader = ...;

// read all entries at once
List<Person> persons = csvPersonReader.readAll();

// read each entry individually
Iterator<Person> it = csvPersonReader.iterator();
while (it.hasNext()) {
Person p = it.next();
// ...
}
3 questions
2
votes
2 answers

How to get proper string array when parsing CSV?

Using jcsv I'm trying to parse a CSV to a specified type. When I parse it, it says length of the data param is 1. This is incorrect. I tried removing line breaks, but it still says 1. Am I just missing something in plain sight? This is my input…
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
1
vote
0 answers

how to maintain end of line character between single quotes with JCSV

I wrote a simple parser using JCSV to parse a csv content, but it seems that it doesn't maintain the end of line character inside enclosed single quotes, is there more configuration in it or JCSV is not capable of it? public class CSVUtil { final…
nightograph
  • 2,179
  • 5
  • 31
  • 49
-1
votes
1 answer

How can i read pipe delimited text using JCSV in java?

In my project,we are using JCSV for reading comma separated values.We wanted to extend the support to read pipe delimited text as well. The text is something like this: NAME|AGE|Sex|Country| Alpha|22|M|Switzerland| Beta|23|F|Germany|
Javaenthu
  • 5
  • 3