Thanks a lot!
The CsvFormat and a Map sounds perfect!
James.Strachan wrote:
>
> On 10/10/2007, borgel <[EMAIL PROTECTED]> wrote:
>>
>> I am trying to use Camel in a project. I am going to do exactly the same
>> thing as in the etl example, except i have to read csv files (comma
>> separated), instead of xml. Do you have a suggestion how to do that?
>>
>> I guess i can't do:
>> from("file:src/data?noop=true").convertBodyTo(PersonDocument.class)
>> directly?
>>
>> I was therefore thinking of something like:
>> from("file:src/data?noop=true").process(csvToXml).convertBodyTo(PersonDocument.class).
>>
>> Do i actually have to go through the PersonDocument.class at all? Can't i
>> just create a transformer that takes a String (content of csv file) and
>> return a CustomerEntity?
>
> So you could just use the bean integration to implement your
> transformation; get the DSL to invoke your transform as a bean...
>
> from("file:src/data?noop=true").bean(new MyTransformerBean());
>
> or even call a specific named method from a bean defined in your
> registry (JNDI or Spring XML etc)
>
> from("file:src/data?noop=true").beanRef("csvToXmlBean", "convert");
>
> Then your convert method could be like this
>
> public class MyTransformerBean {
>
> // adding a parameter annotation so that Camel knows ot invoke
> // this method by default - in case we add more public methods later
> public List<PersonDocument> convert(@Body Reader reader) {... }
>
> }
>
> Incidentally I've added support for pluggable data formats now; so we
> could define a CsvFormat that is capable of reading & writing CSVs...
> http://cwiki.apache.org/CAMEL/data-format.html
>
> The CSV format could either use a Map for each row; or could use a
> specific bean type; then use introspection to get/set each cell value?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>
>
--
View this message in context:
http://www.nabble.com/CSV-file-tf4599797s22882.html#a13133665
Sent from the Camel - Users mailing list archive at Nabble.com.