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

String Array Max is only at 40

my program was not able to get the index array of 41 it has error index array outbound it is separated by comma which is 41 commas when i did get the 40 i did not encounter the error but when it comes to 41 comma it give me an error index array…
-1
votes
2 answers

Convert List to Array int[][]

I need to read matrix from csv-file using OpenCSV library. Function readAll() from OpenCSV return List String[], while I need int[][]. This is what I have: cSVFileReader = new CSVReader(new FileReader(path), ','); List allRows =…
Kat Roz
  • 59
  • 9
-1
votes
1 answer

How to read a untidy csv file in java and create a corresponding ArrayList of an object?

I want to read this csvFile into an array of Flight class objects in which each index will refer to an object containing a record from the csvFile. Here is a blueprint of Flight class. Its not complete so I am only providing the data…
-1
votes
1 answer

Get file size using opencsv, android studio 2.1

I'm trying to export a CSV file with the help of opencsv 3.7. I need to limit the size of my file and I didn't figure how to do it yet. file.size() doesn't help in this situation.
-1
votes
2 answers

How to convert CSV with Double Quotes into OpenCSV using SED or AWK?

I want to convert the CSV with double quotes into OpenCSV (no double quotes and comma is escaped with backslash) using unix utilities SED or AWK. I do find examples with perl or java online, but i am looking for one which is simply done using basic…
Arun Annamalai
  • 785
  • 1
  • 7
  • 20
-1
votes
2 answers

Avoiding ArrayIndexOutOfBoundsException while reading a CSV using CSVReader(OpenCSV) in JAVA 6

This is what I have done, code looks like below : CSVReader reader = new CSVReader(new FileReader("fileName.csv"), ',' , '"' , 1); // using openCSV String[] nextLine; // Declaring the array while ((nextLine = reader.readNext()) != null) { if…
devk
  • 21
  • 1
  • 9
-1
votes
3 answers

convert csv format to Json in android

Example to convert csv format to Json in android. I found a solution in Converting an CSV file to a JSON object in Java but not working or I am missing anything. Thanks in advance. package com.example.readfilefromsdcard; import java.io.File; …
Bhola Nath Mahto
  • 484
  • 5
  • 18
-1
votes
1 answer

Large csv impossible to handle

I am trying to access a 2.2 GB csv file. Excel and R are useless for this. SAS could have worked, but it seems that the file is corrupted and SAS cannot handle that. I am trying to do something with Python, but no luck so far. Any advice would be…
Zoey
  • 3
  • 2
-1
votes
2 answers

Files reading: Out of memory error

I need to browse through around 3000 folders, each folder contains 300 CSV files. This is the error that occurs at line while ((nextLine=csvReader.readNext()) != null): Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit…
Klausos Klausos
  • 15,308
  • 51
  • 135
  • 217
-1
votes
2 answers

Read csv with opencsv

List listfirst(String dir){ try { List list=new ArrayList(); CSVReader reader = new CSVReader(new FileReader(dir)); String [] nextLine; …
-1
votes
1 answer

NullPointerException when writing csv file

I want to write a csv with the opencsv libary, however, when running the code I get a NullPointerException. public void exportToCSV(ArrayList list) throws IOException { log.info("write CSV file"); String writerPath =…
Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
-1
votes
2 answers

parsing CSV file in java when delimiter is a part of data

I am writing a CSV parts.Its easy to write it using java String s = null while( (s= bufferedReadr.readLine() !=null){ String parts[] = s.split(','); //process parts } The problem is data is in format "a", "b","c","d","e","f". But some of the…
user93796
  • 18,749
  • 31
  • 94
  • 150
-1
votes
1 answer

jar file not able to load csv file on a different machine

I m new to java and using Netbeans IDE for my project. I need to read and display csv files so i used opencsv library for that. it is working fine on my computer but the jar file is not able to load any csv file on a different machine. what could be…
user3181652
  • 34
  • 1
  • 5
-1
votes
5 answers

how to count total rows in csv using java

I have a csv file. I want to write a function in Java which will tell me how many rows are there in csv. Could someone please help me in achieving this. csv has following format: "Time","Actual","Time","Expected","Time","Status" "2012-09-01…
Deepak Shah
  • 175
  • 1
  • 2
  • 10
-1
votes
1 answer

Java programs cannot run after downloading opencsv

I downloaded the opencsv (from http://sourceforge.net/projects/javacsv/files/latest/download) and since then I have been getting this error with all my Java programs java.lang.NoClassDefFoundError: HelloWorld Caused by:…
user1285
  • 51
  • 1
  • 4
  • 8