camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Attilio DonĂ  <>
Subject Camel-csv 2.2.0: reading a single line csv file
Date Tue, 04 May 2010 06:57:47 GMT

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> csvData)
    // do magic here as in the manual if the file as more than one row of

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));
		 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));


View this message in context:
Sent from the Camel - Users mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message