Excuse me, I reply only for correcting the first message format.
Attilio

Attilio Donà wrote:
> 
> Hi all,
> 
> I've to read a csv file and I want use camel to do this. Camel bindy seems
> to me that doesn't know the csv convention that a field separator can be a
> character field using double quotes:
> 
> "contains,  comma", "another field" 
> 
> So the adopted solution is camel-csv.
> 
> Using camel-csv to parse the csv file as in the camel manual works only if
> the csv file has more than one line of data:
> 
> // Some comments here
> public void doHandleCsvData(List<List<String>> csvData)
> {
>     // do magic here as in the manual if the file as more than one row of
> data
> }
> 
> If the csv file has 1 row the parameter passed to the method bean
> doHandleCsvData is a List<String>.
> 
> As a quick workaround, instead of using parametrized generics, it is
> possible to do something like this:
> 
> 
>        public void modelsCsvFile(Exchange exchange) {
>                List csvData = (List) exchange.getIn().getBody();
>                
>                if (csvData.get(0).getClass().equals(String.class)) {
>                        log.debug("single row file");
>                        
>                        Vendor vendor = vendorDAO.bind((String)csvData.get(0));
>                        Model model = new Model(vendor, 
> (String)csvData.get(1));
>                        modelDAO.bind(model);
>                        return;
>                }
>                
>                for (List row : (List<List>)csvData) {
>                        log.debug("read [{}] [{}]", row.get(0), row.get(1));
>                        
>                        Vendor vendor = vendorDAO.bind((String)row.get(0));
>                        Model model = new Model(vendor, (String)row.get(1));
>                        modelDAO.bind(model);
>                        
>                }
> 
> Attilio
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Camel-csv-2.2.0%3A-reading-a-single-line-csv-file-tp28443740p28443808.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to