unmarshal(CsvDataFormat) produces a List<List<String>>,
however, it the CSV file has only one line, it produces List<String> instead
of List&lt;List&lt;String&gt;>.

We don't know in advance how many lines the CSV file will have,
that could be zero, one, or more than one,
and we should expect to receive always a List&lt;List&lt;String&gt;>.

Is there an option to always receive a List&lt;List&lt;String&gt;> even if
there is only one line?
We didn't find any documentation about this in the website:
http://camel.apache.org/csv.html


Regards,
David


++++++++++++++++++++++++++++++++++++++++
import org.apache.camel.*;
import org.apache.commons.csv.CSVStrategy;

class Test {
    public static void main(String args[]) throws Exception {
        CsvDataFormat csv = new CsvDataFormat();
        csv.setAutogenColumns(false);
        CSVStrategy strategy = CSVStrategy.DEFAULT_STRATEGY;
        strategy.setDelimiter(',');
        csv.setStrategy(strategy);

        CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("file:files/inbox")
                .unmarshal(csv)
                .process(new MyLog());
            }
        });
    }
}

class MyLog implements Processor {
    public void process(Exchange exchange) throws Exception {
        List&lt;List&lt;String&gt;> data = (List&lt;List&lt;String&gt;>)
exchange.getIn().getBody();
        for (List<String> line : data) {
            System.out.println(String.format("TEST %s - %s - %s",
line.get(0), line.get(1), line.get(2)));
        }
    }
}
++++++++++++++++++++++++++++++++++++++++


--
View this message in context: 
http://camel.465427.n5.nabble.com/unmarshal-CsvDataFormat-different-behavior-for-one-or-multiples-lines-tp4778814p4778814.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to