[
https://issues.apache.org/jira/browse/CSV-258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17042228#comment-17042228
]
Draque Thompson edited comment on CSV-258 at 2/21/20 11:15 PM:
---------------------------------------------------------------
Ack, sorry. Calling it super-csv is my fault. I have been jumping between
multiple CSV tools, I misspoke there. Anyhow, here's how it's being called:
inputFile = <PATH TO FILE>
format = Delimiter:"," QuoteChar: "\"" RecordSeperator: "\n"
{quote}private List<List<String>> getRows(String inputFile, CSVFormat format)
throws FileNotFoundException, IOException {
List<List<String>> ret = new ArrayList<>();
try (
Reader reader = Files.newBufferedReader(Paths.get(inputFile));
CSVParser csvParser = new CSVParser(reader, format)
) {
for (CSVRecord csvRecord : csvParser) {
List<String> row = new ArrayList<>();
for (int i = 0; i < csvRecord.size(); i++)
{ row.add(csvRecord.get(i)); }
ret.add(deNullRow(row));
}
}
return ret;
}
{quote}
was (Author: draque):
Ack, sorry. Calling it super-csv is my fault. I have been jumping between
multiple CSV tools, I misspoke there. Anyhow, here's how it's being called:
inputFile = <PATH TO FILE>
format = Delimiter:"," QuoteChar: "\"" RecordSeperator: "\n"
private List<List<String>> getRows(String inputFile, CSVFormat format) throws
FileNotFoundException, IOException {
List<List<String>> ret = new ArrayList<>();
try (
Reader reader = Files.newBufferedReader(Paths.get(inputFile));
CSVParser csvParser = new CSVParser(reader, format)
) {
for (CSVRecord csvRecord : csvParser) {
List<String> row = new ArrayList<>();
for (int i = 0; i < csvRecord.size(); i++) {
row.add(csvRecord.get(i));
}
ret.add(deNullRow(row));
}
}
return ret;
}
> Error on read of special characters with little endian encoding
> ---------------------------------------------------------------
>
> Key: CSV-258
> URL: https://issues.apache.org/jira/browse/CSV-258
> Project: Commons CSV
> Issue Type: Bug
> Components: Parser
> Affects Versions: 1.8
> Reporter: Draque Thompson
> Priority: Minor
> Attachments: badcharacters.txt
>
>
> Under certain scenarios, super-csv will blow up when consuming special
> characters. To make this error appear:
> # Copy/paste the following CSV data into an empty file:
>
> {quote}{{CONLANG, LOCAL}}
> {{ONE, 1}}
> {{TWO, 2}}
> {{THREE, 3}}
> {{FOURááçõ, 4}}
> {quote} # Save this file with encoding: UTF-16 Little Endian
> # Try to parse the file with super-csv
> Here is the top stack trace I got while using it:
>
> {quote}{{MalformedInputException reading next record:
> java.nio.charset.MalformedInputException: Input length =
> 1-java.lang.IllegalStateException
> java.nio.charset.MalformedInputException: Input length = 1
> at
> java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)
> at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:352)
> at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
> at java.base/java.io.InputStreamReader.read(InputStreamReader.java:181)
> at java.base/java.io.BufferedReader.read1(BufferedReader.java:210)
> at java.base/java.io.BufferedReader.read(BufferedReader.java:287)
> at java.base/java.io.BufferedReader.fill(BufferedReader.java:161)
> at java.base/java.io.BufferedReader.read(BufferedReader.java:182)
> at
> org.apache.commons.csv.ExtendedBufferedReader.read(ExtendedBufferedReader.java:58)
> at org.apache.commons.csv.Lexer.nextToken(Lexer.java:95)
> at org.apache.commons.csv.CSVParser.nextRecord(CSVParser.java:664)
> at
> org.apache.commons.csv.CSVParser$CSVRecordIterator.getNextRecord(CSVParser.java:142)
> at
> org.apache.commons.csv.CSVParser$CSVRecordIterator.hasNext(CSVParser.java:155)}}
> {quote}
> Let me know if there are any other details I can git to help!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)