Shakesbeer
Shakesbeer

Reputation: 91

Jackson MappingIterator: wrong location

MappingIterator gives me the wrong location when iterating through. Here is my setup:

private CsvSchema getCsvSchema(final Class<A> clazz) {
        return csvMapper.schemaFor(clazz)
            .withColumnSeparator(',')
            .withSkipFirstDataRow(true)
            .withoutArrayElementSeparator();
    }
final MappingIterator<A> iterator = csvMapper.readerFor(clazz)
            .with(getCsvSchema(clazz))
            .with(Locale.GERMANY)
            .readValues(fileContent);

with file content:

enter image description here

Iterating through gives me

Anyone sees the issue here?

Correct line and column number. As seen in the binary code, characters for new line are 0D 0A

Upvotes: 0

Views: 22

Answers (1)

burakozgul
burakozgul

Reputation: 797

It seems like jackson parser not recognize 0D 0A (\r\n) as end of line. You can try to replace \r\n with \n String normalizedContent = fileContent.replace("\r\n", "\n"); something like this. Also you can try enabling CRLF end of line csvMapper.enable(CsvParser.Feature.ALLOW_CRLF_FOR_NEW_LINE); like this. If both not worked my second guess is bug occurs cause of localization.

Upvotes: 0

Related Questions