Questions tagged [apache-commons-csv]

Commons CSV reads and writes files in variations of the comma-separated value (CSV) format.

Apache Commons CSV, an open-source Java library for reading and writing text files in various delimited-text formats, including:

114 questions
1
vote
1 answer

Apache commons-csv error with quote

I'm working with org.apache.commons-csv 1.4, this week I discovered in one of our junit test's, this strange behaviuor: CSVReader reader = null; List linesCsv = new ArrayList<>(); FileInputStream fileStream = null; …
reizintolo
  • 429
  • 2
  • 7
  • 20
1
vote
3 answers

Apache commons CSV-parse record with new line chars

How to parse a CSV record that contains new line characters within quotes as below 1, Test, "testing testing testing" I'm currently using Apache CSV lib CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(new FileReader(file));
Kzhunter
  • 597
  • 1
  • 6
  • 19
1
vote
1 answer

Apache commons CSV: quoted input doesn't work

import java.io.IOException; import java.io.StringReader; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; I try to parse a simple csv file with Apache CSV parser. It works fine as long as I don't use quotes. When I…
Balage1551
  • 1,037
  • 1
  • 10
  • 28
1
vote
2 answers

skip double quotes when reading csv file using apache commons csv

Reader in = new FileReader(dataFile); Iterable records = CSVFormat.RFC4180.withFirstRecordAsHeader().withIgnoreEmptyLines(true).withTrim().parse(in); // Reads the data in csv file until last row is encountered for…
Sangam Belose
  • 4,262
  • 8
  • 26
  • 48
1
vote
1 answer

How to read csv file from resources dir in JUnit Test using FileUtils

Have a csv file inside a standard maven project's resources dir as follows: src/main/resources/fruits.csv src/test/resources/fruits.csv fruits.csv Type, Quantity apple, 50 banana, 60 orange, 70 Using the following libraries
PacificNW_Lover
  • 4,746
  • 31
  • 90
  • 144
1
vote
1 answer

Java - Generic class extended by concrete class

I have a number of classes, POJO style, that shares a single functionality, say readCSV method. So I want to use a single parent (or maybe abstract, not sure if it should be) class that these POJOs can extend. Here's a pseudo-code: (abstract) class…
oikonomiyaki
  • 7,691
  • 15
  • 62
  • 101
0
votes
0 answers

error: package com.google.gson does not exist when running

import com.google.gson.Gson; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import java.io.FileReader; import java.io.IOException; import java.io.Reader; import…
0
votes
0 answers

Loading a file via JavaScript from a stream

Hi all! I want to solve the following problem. The java method unloads data from the database and writes the data to the writer. Since you don’t want to store this object in memory and don’t wait on the client side until the entire report is…
0
votes
0 answers

Compare two Lists of CSVRecord objects

I have two List. The CSVRecord is from the Apache commons-CSV library. How do I compare them? The record in the two lists could be in a different order. But I want to find out if the two lists are identical. Is there a clean way to do it? My…
nick
  • 107
  • 6
0
votes
0 answers

Apache Commons DBUtils MapListHandler to get List> How do you save to CSV using Apache Commons CSV

public List> getReport() { Connection connection = createConnection(); List> sqlReport = new ArrayList<>(); if (connection == null) { return sqlReport; } try { …
trilogy
  • 1,738
  • 15
  • 31
0
votes
0 answers

java.lang.NoClassDefFoundError: org/apache/commons/csv/CSVFormat

I am building an app with Spring Boot that reads a CSV file with Apache Commons CSV. When I try to run the app I receive the error: java.lang.NoClassDefFoundError: org/apache/commons/csv/CSVFormat ... I have the next dependency in the…
JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50
0
votes
1 answer

When opened in MS Excel Japanese character shows as garbled character in csv file generated using apache commons csv

We are creating a CSV file, then writing to it using following piece of code (apache commons csv). We are using UTF-8 encoding while creating the file. import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import…
0
votes
1 answer

CSVPrinter adds double quotes at beginning and end of line

I'm using CSVPrinter to create a CSV. @Data public class ExportRecord { String name; String email; String code; @Override public String toString() { return String.join(";", name, email, …
Sven
  • 139
  • 2
  • 3
  • 12
0
votes
0 answers

Auto detect delimiter in CSV using Apache Commons CSV

I am using Apache Commons CSV for parsing CSV files. My application use two type of CSVs with similar headers, one with comma (,) as separator and other has semi colon (;) as separator. Is there any way to autodetect separator in CSV files using…
Ashish Nijai
  • 321
  • 2
  • 13
0
votes
2 answers

Apache commons CSVPrinter is encoding Double values

I am trying to read some data from a list and writing that into a csv file without any formatting or encoding. Just comma separated values but the problem is, when I am writing any value such as 0.0000666, it encoded to 6.66E-5. I want no…
Akif
  • 51
  • 6