Hi I have created a ticket https://issues.apache.org/jira/browse/CAMEL-4440
On Thu, Sep 8, 2011 at 8:20 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > On Wed, Sep 7, 2011 at 4:57 PM, dportabella <david.portabe...@gmail.com> > wrote: >> unmarshal(CsvDataFormat) produces a List<List<String>>, >> however, it the CSV file has only one line, it produces List<String> instead >> of List<List<String>>. >> >> 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<List<String>>. >> >> Is there an option to always receive a List<List<String>> even if >> there is only one line? >> We didn't find any documentation about this in the website: >> http://camel.apache.org/csv.html >> > > I guess it would make sense to align this so the camel-csv always uses > the same way. > > Fell free to create a JIRA ticket about this. > http://camel.apache.org/support > > > >> >> 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<List<String>> data = (List<List<String>>) >> 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. >> > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/