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

OpenCSV - Map multiple CSV columns to single bean attribute

I have a requirement to, combine two CSV columns into one bean attribute. Perform a simple mathematical operation on a column value and map to bean attribute. Wondering if something like this is possible using OpenCSV annotations. Input CSV User…
Priyath Gregory
  • 927
  • 1
  • 11
  • 37
4
votes
2 answers

With OpenCSV, how do I append to existing CSV using a MappingStrategy?

With OpenCSV, how do I append to existing CSV using a MappingStrategy? There are lots of examples I could find where NOT using a Bean mapping stategy BUT I like the dynamic nature of the column mapping with bean strategy and would like to get it…
djangofan
  • 28,471
  • 61
  • 196
  • 289
4
votes
1 answer

How to get the exact name in @CsvBindByName?

When using OpenCSV in order to write csv i'm using the CSVBindByName annotation this way: @CsvBindByName(column = "Date") private Long date; @CsvBindByName(column = "Post content") private String text; But in the generated file the…
Udi
  • 598
  • 8
  • 19
4
votes
2 answers

I can not get the exact number from a csv file if it starts with a zero in ruby

Descriptions Read file csv in ruby. I have a csv file with this content longitude,latitude,phone 13,139.7113134,35.56712836,0311112222 I read file csv. I get data is not expect at column phone number Code uploaded_io =…
Akiko
  • 51
  • 3
4
votes
2 answers

OpenCSV quoting null values

Using the OpenCSV library, calling StatefulBeanToCsv.write() my null values are being wrapped in quotes. Example: String[] columns = new String[] { "Col1", "Col2", "Col3" }; ColumnPositionMappingStrategy strat = new…
Brett
  • 719
  • 1
  • 10
  • 16
4
votes
3 answers

Parse CSV with OpenCSV with double quotes inside a quoted field

I am trying to parse a CSV file using OpenCSV. One of the columns stores the data in YAML serialized format and is quoted because it can have comma inside it. It also has quotes inside it, so it is escaped by putting two quotes. I am able to parse…
invinc4u
  • 1,125
  • 3
  • 15
  • 26
4
votes
3 answers

CSVReader - bug when using " for escape char

I am using OpenCSV. I have a CSVReader trying to parse a CSV file. That file has quote char " and separator char , and escape char also ". Note that the CSV contains cells like: "ballet 24"" classes" "\" which actually represent these…
peter.petrov
  • 38,363
  • 16
  • 94
  • 159
4
votes
5 answers

parse csv, do not split within single OR double quotes

I try to parse a csv with java and have the following issue: The second column is a String (which may also contain comma) enclosed in double-quotes, except if the string itself contains a double quote, then the entire string is enclosed with a…
Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
4
votes
2 answers

A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))

I am using EPPlus to read .csv file in vb.net. When I run this code, I get the error "A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))" Here is my code : Public Function…
Margaretha
  • 57
  • 1
  • 1
  • 8
4
votes
2 answers

Java OpenCSV How to edit specific cells from csv file

I have a CSV file which looks like this: http://gyazo.com/5dcfb8eca4e133cbeac87f514099e320.png I need to figure out how I can read specific cells and update them in the file. This is the code I am using: import java.util.List; import…
Shivam Paw
  • 203
  • 3
  • 14
4
votes
1 answer

Java application Error while reading a csv file using openCSV CSVReader ... java.lang.ArrayIndexOutOfBoundsException

I get an error in my Java application when i try to read a column from each line of my csv file java.lang.ArrayIndexOutOfBoundsException: 1 My code is like this using OpenCSV public void insertOjd(String fichierEntree) throws SQLException { …
Stim
  • 63
  • 8
4
votes
1 answer

Java OpenCSV Writing Result Set - End of Line / Row

I'm trying to export a SQL resultset to a comma delimited csv file using opencsv library. However when I pass the result set to the writeAll function, all works well except for the file that it generates does not separates the rows with a new line…
emu
  • 67
  • 1
  • 4
4
votes
6 answers

Computing Standard Deviation without packages in Python?

I'm trying to figure out how to create a script which calculates a standard deviation for a file. As an example, say I DLed a csv with a list of values on it. I want to find the SD of these values by running a python program. We are not using numpy…
whuan0319
  • 61
  • 1
  • 1
  • 5
4
votes
1 answer

How do I parse a column from a CSV string using jackson CsvMapper or another csv parser?

I have a Java method that receives a CSV string of values and an integer index to reference which column in the CSV string to parse. The method returns the value associated with the integer index in the CSV string. For example if I have a CSV…
erj2code
  • 301
  • 5
  • 9
  • 19
4
votes
1 answer

opencsv writing file with some quoted elements and others unquoted

Does anyone have experience using opencsv in Java to write a csv file where only some of the elements need to be double quoted? The desired output I am looking to test is to make a file that would read: 1,"two",three but when I try the following…
user2012652
  • 41
  • 1
  • 3