[英]Camel split CSV file on regex
I am working on one case where I have csv file with below data 我正在处理具有以下数据的csv文件的一种情况
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 当我使用XML时的示例可以在路由中解析XML
I cannot use Camel-Bindy as I don't have fixed delimiters in row 我无法使用Camel-Bindy,因为我在行中没有固定的定界符
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. 它们的长度是可变的,我已经在bean中处理过了。 Is there any way where I can parse or use any regex? 有什么方法可以解析或使用任何正则表达式?
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: 作为分隔符,您可以使用默认的CSV支持将内容加载为列表列表,然后拆分正文以将每一行作为列表获取,然后在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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.