Questions tagged [opencsv]

opencsv is a simple csv (comma-separated values) parser library for Java

What is opencsv ?

opencsv is a simple csv (comma-separated values) parser library for Java. It was developed in response to a lack of csv parsers with commercial-friendly licenses.

Where can I get it?

Source and binaries are available from Sourceforge. You can check out the javadocs online.

What features does opencsv support?

opencsv supports all the basic csv-type things you're likely to want to do:

  • Arbitrary numbers of values per line
  • Ignoring commas in quoted elements
  • Handling quoted entries with embedded carriage returns (ie entries that span multiple lines)
  • Configurable separator and quote characters (or use sensible defaults)
  • Read all the entries at once, or use an Iterator style model
  • Creating csv files from String[] (ie. automatic escaping of embedded quote chars)
1008 questions
0
votes
2 answers

CSV parser skips the empty cell by default

Here is my csv 0|A0|B0||D0 1|A1|B1|C1|D1 Here is the csvParser i am using file.eachLine() { line -> if (!line.startsWith("0")) { def field = line.tokenize("|") lineCount++ …
RSM
  • 423
  • 3
  • 7
  • 20
0
votes
1 answer

List of List to string ordered string array

I am having a resultList which is a string list were each element in this list is also a List. Now I want to put my data into a csv sheet. For that I am using opencsv. List data = new ArrayList(); for(int m = 0;…
user2051347
  • 1,609
  • 4
  • 23
  • 34
0
votes
0 answers

add marker to check if program is done updating the CSV file

I have a program that outputs csv file and add entries continuously. My second program reads the csv file, I need an EOF marker that can be recognized by OpenCsv, once the eof marker is read my second program will then check for a new file. I'm…
0
votes
1 answer

How to write only the 5th value from a list into a csv

I am reading several csv sheet with the opencsv libary. I am storing the "read" csv file in hugeList = reader.readAll(); Now I only want to only write the 5th value of this huge csv sheet columnwise in another sheet. At the moment I am standing at: …
user2051347
  • 1,609
  • 4
  • 23
  • 34
0
votes
3 answers

Android: java.lang.NoClassDefFoundError for class extended from "java" library

Following is the snap shot of the eclipse's package explorer. I use the opencsv library for the app project. I added the jar to referenced libraries in main project. I define a class 'X' in main project that extends a class from the jar library…
user2432627
  • 157
  • 1
  • 2
  • 14
0
votes
2 answers

dump oracle table to csv. date converting

Have a problem with dumping oracle table to csv file. Problem is in date dumping I get date like "23-Jun-2009" with current code, but I need something like "2009-06-23 20:18:44". I get right date date, if put code while(result.next()) { …
0
votes
3 answers

how to read two consecutive commas from .csv file format as unique value in java

Suppose csv file contains 1,112,,ASIF Following code eliminates the null value in between two consecutive commas. Code provided is more than it is required String p1=null, p2=null; while ((lineData = Buffreadr.readLine()) != null) …
AbdulSaleem
  • 154
  • 1
  • 3
  • 18
0
votes
2 answers

Populate String[7] with data even if I don't have 7 items from my parser?

I am populating a list array with lines from a csv file. I have some empty columns and some not. I would like these empty columns to contain "0" if they are empty. The length of the string[] could be 1 to 7. However, I need to return 7 items when…
jasonflaherty
  • 1,924
  • 7
  • 40
  • 82
0
votes
1 answer

Parse CSV with some empty fields. Make sure array always has X items. Using OpenCSV

I have data like this: Redfish Creek Snow Pillow,2013-11-21 17:00:00,-9.9,557,321,125,14.7 However, sometimes it has NULL items in the columns... see the last two. Brenda Mines Snow Pillow,2013-11-24 05:00:00,-5.065,363,58,, These are…
jasonflaherty
  • 1,924
  • 7
  • 40
  • 82
0
votes
4 answers

printing out csv file in specific format?

I'm reading from a csv file which has this layout: CS4092,B CS2013,A CS8291,C CS0927,D CS0281,A When I do print it out, I get this output: CS4092 BMA4042 CCS4023 ACS4075 BCS4010 A The output I'm trying to achieve is: CS4092 - B CS2013 -…
ASmoothNoble
  • 39
  • 1
  • 5
0
votes
3 answers

Retrieve 1 value from CSV and then add all values to first value, individually without a List

I'm developing a Java application in which I store values to a CSV. I need to retrieve one value from one line of a CSV, and then add all values from that line of the CSV including that one to the first value, individually. I need to do that for all…
hichris123
  • 10,145
  • 15
  • 56
  • 70
0
votes
1 answer

opencsv values of one line are not separated

I have a csv list like this: abc;def;ghi; jkl;mno;p; qrs;tuv;wxy; z;zz;zzz; When parsing with opencsv like this: CSVReader reader = new CSVReader(new FileReader("tmplist.csv")); String[] nextLine; int lineNumber = 0; while ((nextLine =…
JoachimR
  • 5,150
  • 7
  • 45
  • 50
0
votes
1 answer

Java Heap Size and OutofMemory

I am trying to read a file (tab or csv file) in java with roughly 3m rows; have also added the virtual machine memory to -Xmx6g. The code works fine with 400K rows for tab separated file and slightly less for csv file. There are many LinkedHashMaps…
Ramin
  • 891
  • 2
  • 10
  • 16
0
votes
0 answers

If we have a bean (i.e an object) inside a java bean rather than primitive type the how we map internal bean's property using OpenCSV

If we have a bean (i.e an object) inside a java bean rather than primitive type the how we map internal bean's property using OpenCSV for example flightId of flight BEANS SCHEDULE(scheduleId,flight,route,and other fields) Flight(flightid,other…
satishkhowal
  • 97
  • 3
  • 9
0
votes
1 answer

openCSV library removing quotes from variable

I am attempting to parse a csv file with opencsv. The last column in the file has a parameter which is actually json. This json is enclosed in "". The problem is opencsv is removing some " from inside the json causing my code to break. …
user2524908
  • 861
  • 4
  • 18
  • 46