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
7
votes
3 answers

Download CSV file via Rest

Using OpenCSV, I can successfully create a CSV file on disc, but what I really need is to allow users download the CSV with a download button, I don't need to save on disk, just download. Any ideas? @GET @Path("/downloadCsv") public Object…
Spring
  • 11,333
  • 29
  • 116
  • 185
7
votes
2 answers

openCSV not reading my entire file

I have an application in Java that I am using openCSV to read a file (very large). I am then putting the 4th (Eventually this will have another column or two added if that makes a difference) column into a HashSet and outputting that to a new file.…
Hirthas
  • 359
  • 2
  • 13
6
votes
0 answers

Opencsv, StatefulBeanToCsv write nested List of Objects to csv

I have to write nested list of objects(StoreLocations) into Csv file using open csv. My model classes are- public class StoreLocation { private String name; private String city; private int zip; private String streetAndNumber; …
Caffeine Coder
  • 948
  • 14
  • 17
6
votes
1 answer

OpenCSV: Mapping a Nested Bean to a CSV file

I am trying to map a bean to a CSV file but the problem that my bean has other nested beans as attributes. What happens is that OpenCSV goes through the attributes finds a bean then goes into it and maps all the data inside of that bean and if it…
yasseen
  • 101
  • 3
  • 7
6
votes
2 answers

OpenCSV - register custom converter

So I'm using opencsv to convert a csv to beans. This all works fine with primitive values, but I want to use enums and this is giving some issues. I'm going through the code, and it seems I need to completely implement a new mappingstrategy to do…
Kristof Plennings
  • 469
  • 1
  • 6
  • 17
6
votes
0 answers

OpenCSV fails to parse double quote next to each other

I've upgraded our OpenCSV version from 1.8 to 4.1. With version 4.1 OpenCSV fails to parse the following lines: MODIFY ACEUD-2052 TVG00420 8806088726823 0 645.88 TV Gerät LED-LCD 140 cm (55) Samsung UE55MU6402 (1500Hz,SmartTV,4K)…
dazito
  • 7,740
  • 15
  • 75
  • 117
6
votes
1 answer

Using CSV Serde with Hive create table converts all field types to string

If I create a table and specify a CSVSerde then all fields are being converted to string type. hive> create table foo(a int, b double, c string) row format serde 'com.bizo.hive.serde.csv.CSVSerde' stored as textfile; OK Time taken: 0.22…
awhan
  • 510
  • 6
  • 13
6
votes
1 answer

ColdFusion/Java Class not found Exception

I am trying to parse a CSV File with Coldfusion and a JavaLibrary. I found some examples but it seems that ColdFusion cannot find the Jar-File. This is my Code: fileReader =…
noah
  • 174
  • 9
6
votes
3 answers

How to Read and Write to a csv file in Android?

I want to store 8 integers into a .csv file(the filename will be taken as an input from a EditText) and retrieve them when I want to.
6
votes
3 answers

Scala: Auto detection of delimiter/separator in CSV file

I'm using OpenCSV library for split my CSV files. Now i need to detect the delimiter/separator character with absolute certainty. I have searched on the net but I only found examples where you create a list of candidates and try one of these. I do…
YoBre
  • 2,520
  • 5
  • 27
  • 37
5
votes
0 answers

OpenCsv: Can I specify the locale once instead of repeating it in every @CsvBindByName?

I'm using OpenCSV to parse csv files which needs to work when run in both the UK and Germany. When parsing numbers we need to specify the locale so that OpenCSV knows which decimal separator ('.' for UK, ',' for DE) and thousands separator (',' for…
lance-java
  • 25,497
  • 4
  • 59
  • 101
5
votes
1 answer

CsvMalformedLineException: Unterminated quoted field at end of CSV line

I am writing code to process a list of tar.gz files, inside which there are multiple, csv files. I have encountered the error below com.opencsv.exceptions.CsvMalformedLineException: Unterminated quoted field at end of CSV line. Beginning of lost…
Ziqi
  • 2,445
  • 5
  • 38
  • 65
5
votes
1 answer

How do I build a (working) custom converter with opencsv

I'm using OpenCSV with a nested bean structure. However, I need a custom converter to pull this off (currently focussing on the writing to csv part). I've looked around but I've not found any examples to help me figure out how to make it work. I've…
SaurPuss
  • 88
  • 1
  • 7
5
votes
1 answer

Fastest and efficient way to parse a large CSV file in java

I want to parse the large CSV file as fast and efficient as possible. Currently, I am using the openCSV library to parse my CSV file but it is taking approx 10sec to parse a CSV file which has 10776 records with 24 headings and I want to parse a…
David
  • 507
  • 2
  • 6
  • 14
5
votes
2 answers

Hive table from CSV. The line termination in quotes

I try to create table from CSV file which is save into HDFS. The problem is that the csv consist line break inside of quote. Example of record in CSV: ID,PR_ID,SUMMARY 2063,1184,"This is problem field because consists line break This is not new…
Juraj
  • 738
  • 2
  • 9
  • 26