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
3
votes
1 answer

Null pointer excpetion with opencsv CsvToBean

I am trying to convert all rows in a CSV file into a java bean using openCSV.Each row has 21 columns in my file separated with pipe symbol(|).But getting null pointer exception with this code.rows in csv file include empty cells also.I am not able…
3
votes
2 answers

How to handle processing large csv file or read large CSV file in chunks

I have very large csv files that I'm trying to iterate through. I'm using opencsv and I'd like to use CsvToBean so that I can dynamically set the column mappings from a database. The question I have is how to do this without grabbing the entire file…
Code Junkie
  • 7,602
  • 26
  • 79
  • 141
3
votes
2 answers

Limitation of OpenCSV Reader-Java

I used OpenCSV Reader - java to load my CSV File (file size:-1.47 GB (1,585,965,952 bytes)). However, inside my coding, whenever it only manage to insert 10950 record to PostgreSQL database. CSVReader csvReader = new CSVReader(new…
user1823924
3
votes
5 answers

OpenCSV not escaping the quotes(")

I have a CSV file which will have delimiter or unclosed quotes inside a quotes, How do i make CSVReader ignore the quotes and delimiters inside quotes. For example: 123|Bhajji|Maga|39|"I said Hey|" I am "5|'10."|"I a do "you"|get that" This is the…
BhajjiMaga
  • 221
  • 2
  • 4
  • 15
3
votes
1 answer

"import au.com.bytecode.opencsv.CSVReader" Error

I'm making a java program for converting from CSV file type to XML file type , I needed to import "open CSV" but when I write "import au.com.bytecode.opencsv.CSVReader; " It's being underlined with red , and there's error telling me that " package…
Essam wageh
  • 39
  • 1
  • 4
3
votes
2 answers

Need to delete empty columns in csv

I have created CSV file using Open CSV library using some run time data coming from different datasource. Now I am looking a lot of empty columns which doesn't have value in column cells and so I want to delete that programmatically. Approach I am…
S Singh
  • 1,403
  • 9
  • 31
  • 47
3
votes
2 answers

NoClassDefFoundError after adding Opencsv jar to project

I've added the open csv jar to my project to enable data to be written out to file in csv format. The jar file was added using the following steps: 1.Properties --> Add external jars --> opencsv-3.1.jar 2.Order & Eport tab --> tick,…
Brian Var
  • 6,029
  • 25
  • 114
  • 212
3
votes
3 answers

File reading using OpenCSV

I use OpenCSV for CSV files reading and writing. It worked fine until I hsd to install earlier version of Java - i.e. Java 6. After installing it, my code stopped working: Exception in thread "main" java.lang.UnsupportedClassVersionError: …
Klausos Klausos
  • 15,308
  • 51
  • 135
  • 217
3
votes
1 answer

Get number of columns using OpenCSV

I have a txt file and I want to count the number of columns. (I use openCSV) public class demoTable { public demoTable(){ read(); JOptionPane.showMessageDialog(null, "number of columns inside file: " +…
Vassilis De
  • 363
  • 1
  • 3
  • 21
3
votes
2 answers

Write CSV with text in quotes, but numerical values without quotes

Using OpenCSV, I'm trying to write a CSV file in which Text values are surrounded by " quotes. Numerical values are not surrounded by quotes (because they should be treated as numbers, not as strings, by the program that will eventually read the…
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
3
votes
4 answers

Parsing a CSV file with custom String separator

I tried to parse a CSV file with two APIs - JSefa and OpenCSV - but the problem is that the separator in the CSV file is a double tab "\t\t" and the APIs only accept a character, not a string, for the separator. Is there any other API that could…
Jad B.
  • 1,403
  • 15
  • 14
3
votes
2 answers

IndexError: list index out of range - python

I have the following error: currency = row[0] IndexError: list index out of range Here is the code: crntAmnt = int(input("Please enter the amount of money to convert: ")) print(currencies) exRtFile = open ('exchangeRate.csv','r') …
user3165683
  • 347
  • 1
  • 9
  • 28
3
votes
2 answers

Skipping alternate lines while reading .tsv file

I have a .tsv file which has 39 column the last but one column has data as string whose length in more than 100,000 characters Now what is happening is when i am trying to read the file line 1 has headers and then the data follows What is happening…
Subhrajyoti Das
  • 2,685
  • 3
  • 21
  • 36
3
votes
1 answer

JPA: export query result to CSV format

Which is the best way to export a JPA query result in a CSV format? I tried opencsv but it wants a java.sql.ResultSet object and I don't understand how to create it. I tried the following code public ResultSet getAllUsersMap() { String query =…
Enrico Morelli
  • 185
  • 3
  • 16
3
votes
2 answers

ArrayIndexOutOfBoundsException - when parsing a csv file

I want to transform a csv file. My file looks like that: I am using the opencsv libary to parse my csv. That is my run method to parse the file: public void run() throws Exception { CSVReader reader = new CSVReader(new…
Carol.Kar
  • 4,581
  • 36
  • 131
  • 264