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)
840 questions
6
votes
2 answers

Athena unable to parse date using OpenCSVSerde

I have a very simple csv file on S3 "i","d","f","s" "1","2018-01-01","1.001","something great!" "2","2018-01-02","2.002","something terrible!" "3","2018-01-03","3.003","I'm an oil man" I'm trying to create a table across this using the following…
Kirk Broadhurst
  • 25,044
  • 13
  • 91
  • 149
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…
6
votes
1 answer

Didn't find class "java.beans.Introspector" when Using OpenCSV to parse csv files

i am working on parsing .csv files using OpenCsv for my android application . I writing code in kotlin . Here is my code : This is how i parse the csv file: val beans: List = CsvToBeanBuilder(FileReader(file)) …
Pardeep Kumar
  • 730
  • 10
  • 27
6
votes
2 answers

Appending to CSV file without headers

I am using opencsv to write a Java bean to a CSV file with headers. The file name contains the current date. If the user runs it for a second time in the same day, it appends to the file but adds another header line. How do I append to the file but…
Radika Moonesinghe
  • 187
  • 1
  • 5
  • 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
  • 6,832
  • 11
  • 63
  • 107
6
votes
1 answer

Reading semicolon delimited csv

I have the below block of code which uses OpenCSV to read a CSV file and store the 7th column. The problem I face is that I use ; as delimiter in the CSV file but it takes , as delimiter as well. How can I avoid this? Putting "" in CSV is not…
Sourav Mehra
  • 329
  • 1
  • 5
  • 15
6
votes
2 answers

OpenCSV convert csv to nested bean

We are using OpenCSV. The csv is as id,fname,lname,address.line1,address.line2 The beans are Person{ String id; String lname; String fname; Address address; } Address{ String line1; String line2; } Is it possible to fill the nested…
Alireza Fattahi
  • 33,509
  • 12
  • 96
  • 140
6
votes
3 answers

OpenCSV Avoid using FileWriter and return InputStream

I am using OpenCsv and the new CSVWriter() method takes a Writer as an argument. What I am trying to achieve is that to avoid writing to the file system and instead return an InputStream. I am not sure how to go about this. Not very familiar with…
Aniks
  • 603
  • 1
  • 14
  • 24
6
votes
2 answers

OpenCsv writes wrong column names with BeanToCsv + HeaderColumnNameTranslateMappingStrategy

I'm using opencsv 3.6 in order to create a csv file starting from a java bean. First of all, I tried this code: import com.opencsv.CSVReader; import com.opencsv.CSVWriter; import com.opencsv.bean.BeanToCsv; import…
Baduel
  • 501
  • 3
  • 12
  • 30
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
  • 500
  • 5
  • 11
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
  • 164
  • 9
6
votes
2 answers

Reading *.csv files from directory and showing the content of each file fails

I need help with reading the folder and opening / outputting the csv data, I have used examples other people have written but none of them have worked for me. What I currently have is this, but it doesn't output the files: $files =…
6
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
  • 8,976
  • 26
  • 96
  • 175
6
votes
3 answers

Read large CSV in java

I want to read huge data from CSV, containing around 500,000 rows. I am using OpenCSV library for it. My code for it is like this CsvToBean csvConvertor = new CsvToBean(); List list = null; try { list…
Ninad Pingale
  • 5,634
  • 4
  • 24
  • 45
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
  • 78
  • 7
1 2
3
55 56