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

How to avoid backslash before comma in CSVFormat

I am creating a CSV file using CSVFormat in java, the problem i am facing in both header and values is whenever the string is long and there is a comma the api is inserting a \ before the comma always. As a result the header is not forming correctly…
Mandrek
  • 1,159
  • 6
  • 25
  • 55
0
votes
0 answers

Output a specific format with Apache Commons CSV

I'm trying to output a csv file with the following format ="1000402999574",6456,="21, Street, Town" The reason is that I need the long number to be loaded as text in excel so it isn't converted to a scientific notation. What are the settings…
muttonUp
  • 6,351
  • 2
  • 42
  • 54
0
votes
2 answers

Unable to Parse header from github CSV URL using Apache Commons

I'm trying to access the header values for each record which is present in CSV file url from github using Apache commons csv library. This is my code: @Service public class CoronaVirusDataService { private static String virus_data_url =…
Rahul
  • 65
  • 1
  • 6
0
votes
1 answer

How to use Commons CSV remove duplicate in csv file using Java?

I have a csv file. It contains several duplicate columns. I am trying to remove these duplicates using Java. I found Apache Common csv library, some people use it to remove duplicate rows. How can I use it to remove or skip duplicate columns? For…
0
votes
2 answers

Text qualifier - invalid char between tokn encapsulated and delimiter

If there is a comma in the field, but the whole is closed with quotation marks, then I should not treat it as a column divider. How can this be done? Example aaaa, "bb,bb", cccc and I get aaaa | bb | bb |ccc How can I receive aaaa | "bb,bb" | cccc …
0
votes
1 answer

Apache CSV Quote Character Does Not Work For Multiple Columns

I read a very simple CSV file like this: String csv = "'ID', 'fruit'\n'1', 'apple'\n'2', 'banana'\n'3', 'cherry'"; try (InputStream resourceInputStream = new ByteArrayInputStream(csv.getBytes()); InputStreamReader inputStreamReader = new…
Stefan S.
  • 3,950
  • 5
  • 25
  • 77
0
votes
2 answers

Using Same Escape and Quote Character Breaks CSV

I have a simple CSV file like this: SellerProductID;ProductTextLong 1000;"a ""good"" Product" And this is the try to read it in with Apache CSV: try (Reader reader = new StringReader(content)) { CSVFormat format =…
Stefan S.
  • 3,950
  • 5
  • 25
  • 77
0
votes
1 answer

Java: Using InputStream and Apache Commons CSV without line numbers

This is probably very simple, but I have not been able to find an option to do this. I'm trying to Apache Commons CSV to read a file for later validations. The CSV in question is submitted as an Input Stream, which seems to add an additional column…
SVill
  • 331
  • 5
  • 22
  • 55
0
votes
1 answer

Consume JSON from another API using Apache Camel and write it in CSV

I am new in apache camel. I would like to consume json data from another api's end point url (http://localhost:8080/employeePayload). I would like to consume this json data, unmarshal it to a POJO using apache camel and write it to CSV file. Before…
Sri
  • 51
  • 1
  • 7
0
votes
1 answer

Under what circumstances will the constructor of apache.commons.csv.CSVPrinter throw an IOException?

According to the documentation of org.apache.commons.csv.CSVPrinter, an IOException will be thrown "if the optional header [provided in the second argument] cannot be printed". But what would cause the optional header to be unable to print? Are some…
Mathew Alden
  • 1,458
  • 2
  • 15
  • 34
0
votes
0 answers

Select rows for column value from CSV java

I have a CSV ordered based on the value of the "url" column. I would like to select the first three rows for each "url" value. If the rows, for the url value, are less than 3 (2 or 1), I would like to select them anyway. The starting CSV is the…
ramos
  • 3
  • 4
0
votes
1 answer

How to read CSVRecord in apache beam?

I have a Java Iterable object, Iterable records. And I want to pass it to the Beam pipeline. I tried PCollection csvRecordPC = p.apply("Create collection", Create.of(records)); It caused an error An exception occured while executing the Java…
sheng666
  • 49
  • 6
0
votes
0 answers

Editing CSVRecord else creating CSVRecord from Map

My Use case is to edit a CSVRecord. I am reading a csv file and need to edit only one column in record on conditional basis. If condition satisfies then need to edit and print to another file else need to print as it is. Any help in how to achieve…
SRana
  • 125
  • 1
  • 12
0
votes
1 answer

Getting Duplicate while trying to read CSV file with Apache Common CSV

I have a class that try to read a CSV file using Apache Common CSV, so far my code is working fine except that am not getting the result am expecting. My code is displaying a duplicate of the second column in the csv file as…
Chukwu Remijius
  • 37
  • 1
  • 10
0
votes
1 answer

Customize CSVFormat.RFC4180

I have to read a csv file. The file can contain any delimtier and can be enclosed by ""\" or not. The file should also be parsed regarding RFC4180. (I know that in RFC4180 the delimiter is a ",", but a user should also be able to read a file…
Pascal Petruch
  • 344
  • 3
  • 16