Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

CSVMapper does not correctly parse objects with duplicate values. #41

@Claudenw

Description

@Claudenw

Duplicate column value when parsing objects from the input stream with a schema causes dropped data.

It appears that the mapper uses the value for the column name and therefor, when there are duplicate data elements, only one is returned.

Example contained in code below.

public static void main(String[] args) throws JsonProcessingException,
            IOException {

        String dataString="\"foo\",\"bar\",\"foo\"";
        ByteArrayInputStream bais = new ByteArrayInputStream(dataString.getBytes());
        CsvSchema schema = CsvSchema.builder().addColumn("Col1").addColumn("Col2")
                .addColumn("Col3").build();

        MappingIterator<Object> iter = new CsvMapper().reader(Object.class)
                .with(schema).readValues(bais);

        Object o = iter.next();
        Map<?, ?> colData = (Map<?, ?>) o;

        System.out.println("I think this should be: "+schema );
        System.out.println(colData.keySet());
        System.out.println("I think this should be: "+dataString );
        System.out.println(colData.values());

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions