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

Apache commons csv

I can't understand the core of apache commons csv library. Could you advice a method I should use when I want to get columns by header name from csv file by apache-commons-csv? For example, I have such csv file: Delays, Computation time,…
Kenenbek Arzymatov
  • 8,439
  • 19
  • 58
  • 109
2
votes
2 answers

Parsing CSV in groovy with exception tolerance

I've been trying to parse a csv file in groovy, currently using the library org.apache.commons.csv 2.4. The requirement I have is that there are invalid data value in csv cells, such as invalid characters, and instead of throwing an exception on…
James Jiang
  • 2,073
  • 6
  • 19
  • 25
1
vote
2 answers

Escape special meaning of # (double quote) in Apache commons-csv

HELLO printing in a double quote in .tsv file because of '#' like "#HELLO". I want to remove the double quotes when it writes to .tsv current output -> "#HELLO" expected output -> #HELLO try ( CSVPrinter printer = new CSVPrinter(new…
1
vote
1 answer

After modularizing my java project how can I reference org.apache.commons.* libraries

VSCode + Java 11 I am using the Apache commons libraries for a number of things in my project, specifically org.apache.commons.csv and org.apache.commons.io. I am including the jar files for both in my classpath and I was building just fine until I…
Simon
  • 78,655
  • 25
  • 88
  • 118
1
vote
1 answer

Java commons-csv doesn't parse header

I have an EXCEL CSV file with this content: access_id;logicalgate 123456789;TEST As you can see header has strings and are not quoted. With this code: fileReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); csvParser = new…
Tobia
  • 9,165
  • 28
  • 114
  • 219
1
vote
0 answers

CsvToBean equivalent for apache-commons-csv?

I've read about a dozen tutorials showing how to use OpenCSV and apache-commons-csv to parse CSV files. That's all nice and works for me. But one thing always catches my attention: OpenCSV has the CsvToBean untility class which makes it so nice to…
Daniel S.
  • 6,458
  • 4
  • 35
  • 78
1
vote
0 answers

org.apache.commons.csv.CSVRecord.values() has default access

org.apache.commons.csv.CSVRecord.values() gives me the record values. But, it is having default access specifier as of commons-csv-1.5.jar. To get the values, I created a org.apache.commons.csv.MyCSVRecord class and delegated the call to…
cyrilantony
  • 274
  • 3
  • 14
1
vote
2 answers

Create CSV file with columns and values from HashMap

Be gentle, This is my first time using Apache Commons CSV 1.7. I am creating a service to process some CSV inputs, add some additional information from exterior sources, then write out this CSV for ingestion into another system. I store the…
ManxDev
  • 98
  • 2
  • 12
1
vote
1 answer

How to convert CSVRecord to List?

I need to convert a CSVRecord to a List to get the position of an element. So I used this : List records = csvParser.getRecords(); int i = records.get(0).indexOf(element); However, records.get(0) returns a List and not a…
Royce
  • 1,557
  • 5
  • 19
  • 44
1
vote
1 answer

How to write in specific cell in a CSV file?

I need to write in a specific cell in a .csv file with org.apache.commons.csv library whitout iterate and copy all lines. I tried this: Reader reader = Files.newBufferedReader(Paths.get(Properties.dataFilePath)); CSVParser csvParser = new…
Royce
  • 1,557
  • 5
  • 19
  • 44
1
vote
1 answer

Duplicate Header Names Apache Commons-csv (withAllowDuplicateHeaderNames doesn't work)

I am using the last version of common-csv library, such as in my pom.xml I have this dependency: org.apache.commons commons-csv 1.7 This library is used…
1
vote
2 answers

How to ignore a record in the last line of the CSV file using Apache Commons CSV java?

I'm using Apache Commons CSV to read a CSV file. The file have an information about the file itself (date and time of generation) at the last line. |XXXX |XXXXX|XXXXX|XXXX| |XXXX …
1
vote
2 answers

Not able to read more than record through Apache commons csv

I have csv file like this :- a,b,c,d //<- header 0.1,0.123,2.13,3.22 0.3,0.213,2.11,3.12 0.5,0.231,2.3,3.21 0.7,0.121,2.26,3.321 I am using apache commons csv to read the csv file. I have made the POJO which corresponds to the above…
AConsumer
  • 2,461
  • 2
  • 25
  • 33
1
vote
1 answer

Why is Apache commons csv parser appending unique data into 2nd result set?

I have 2 CSV files (district1.csv, district2.csv) in a directory, each containing a column schoolCode. When I read both CSV files with the Apache commons CSV library, I am reading the distinct values of the schoolCode column and counting up the…
ktaylor
  • 13
  • 2
1
vote
2 answers

How to read csv since header inclusively in apache commons csv?

Following approach allows to read with skipping header: Iterable records = CSVFormat.EXCEL.withHeader().parse(in); for (CSVRecord record : records) { //here first record is not header } How can I read csv since header line…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710