Reputation: 1952
I am working on one case where I have csv file with below data
100| Some Delimited Data
200| Some Delimited Data
100| Some Delimited Data
400| Some Delimited Data
400| Some Delimited Data
200| Some Delimited Data
I am trying to make camel route where
when 100
marshal csv & send to Bean
when 200
marshal csv & send to bean
I am trying to route it with camel. Example when I do in XML I can parse XML in route
I cannot use Camel-Bindy as I don't have fixed delimiters in row
example
Row 1 can have 10 '|' (pipes / delimiter)
Row 2 can have 20 '|' (pipes / delimiter)
Row 3 can have 16 '|' (pipes / delimiter)
They are variable in length which I have handled in bean. Is there any way where I can parse or use any regex?
Upvotes: 3
Views: 1031
Reputation: 5369
Since you are always using |
as a delimiter, you can use the default CSV support to load the content as a list of lists, then split the body to get each row as a list and then process that list (row) in your bean:
<unmarshal>
<csv delimiter="|"/>
</unmarshal>
<split>
<simple>${body}</simple> <!-- Body will be a list of lists -->
<choice>
<when>
<simple>${body[0]} == '100'</simple>
<to uri="bean:processor100"/>
</when>
<when>
<simple>${body[0]} == '200'</simple>
<to uri="bean:processor200"/>
</when>
</choice>
</split>
Upvotes: 3