Gautham Arunachalam created CSV-312:
---------------------------------------

             Summary: CSV Header with multiple lines throughs error
                 Key: CSV-312
                 URL: https://issues.apache.org/jira/browse/CSV-312
             Project: Commons CSV
          Issue Type: Bug
          Components: Parser
            Reporter: Gautham Arunachalam


CSV file header is in multi-line while trying to read the file invalid char 
between encapsulated token and delimiter error is thrown

 

Sample CSV:

 
{code:java}
"SYMBOL
","COMPANY
","PURPOSE
","DETAILS
","DATE
"
"AURIONPRO","Aurionpro Solutions Limited","Fund Raising","To consider and 
approve the Issue price, including a discount if any","08-Apr-2024"
"CUPID","Cupid Limited","Financial Results/Other business matters","To consider 
and approve the financial results for the period ended March 31, 2024 and other 
business matters","08-Apr-2024"
"DPWIRES","D P Wires Limited","Other business matters","To consider other 
business matters","08-Apr-2024" {code}
Code used to read

 

 
{code:java}
Reader in = new FileReader(file);

Iterable<CSVRecord> records = CSVFormat.RFC4180.parse(in);

for (CSVRecord record : records) {
  System.out.println(record.get(0));
} {code}
Occurring Error : 
{code:java}
Exception in thread "main" java.io.UncheckedIOException: IOException reading 
next record: java.io.IOException: (line 2) invalid char between encapsulated 
token and delimiter
    at 
org.apache.commons.csv.CSVParser$CSVRecordIterator.getNextRecord(CSVParser.java:150)
    at 
org.apache.commons.csv.CSVParser$CSVRecordIterator.hasNext(CSVParser.java:160)
    at com.gautham.stockmarket.tools.Main.main(Main.java:21)
Caused by: java.io.IOException: (line 2) invalid char between encapsulated 
token and delimiter
    at org.apache.commons.csv.Lexer.parseEncapsulatedToken(Lexer.java:369)
    at org.apache.commons.csv.Lexer.nextToken(Lexer.java:290)
    at org.apache.commons.csv.CSVParser.nextRecord(CSVParser.java:770)
    at 
org.apache.commons.csv.CSVParser$CSVRecordIterator.getNextRecord(CSVParser.java:148)
    ... 2 more {code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to