Do you want also that the CSV generated contain double quotes like
"xxxx","yyyy " ?

KR,

charles

Claus Ibsen-2 wrote:
> 
> Hi
> 
> On Tue, May 4, 2010 at 8:57 AM, Attilio Donà <[email protected]>
> 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"
>>
> 
> Yeah that would be good to be able to do with camel-bindy. Do you mind
> creating a JIRA ticket?
> 
> 
>> 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> 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.
>>
>> 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)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-tp28443740p28443740.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 


-----
Charles Moulliard
SOA Architect

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

Reply via email to