Just a quick and perhaps "dirty"solution, couldn't you rewrite it as below
? Your bean contains a method that simply saves the row as a key value in a
map. But do you want a complete map of all the rows or different maps for
the different rows?
from("file:{{filepath}}?noop=true")
split(body().tokenize("\n"))
.streaming()
.when().body().startsWith("0001")).bean("SavetoMap")
.when().body().startsWith("0002")).bean("SavetoMap")
.when().body().startsWith("0003")).bean("SavetoMap")
On Tue, Mar 7, 2017 at 7:33 AM, chanti [via Camel] <
ml-node+s465427n5794986...@n5.nabble.com> wrote:
> Hi I'm new to camel , I have a issue in splitting a file based on content
> .The below code only splitting one list of lines (ex: 0001 in the file
> file) , I want to split the file based on the content(like 0001,0002,003)
> and aggregate it as a one Map object. can anybody help me this.
>
>
> My code is like this ,
>
> from("file:{{filepath}}?noop=true")
> .split(body().tokenize("\n"))
> .streaming()
> .filter(body().startsWith("0001"))
> .filter(body().startsWith("0002"))
> .filter(body().startsWith("0003"))
> .unmarshal(bindy)
> .aggregate(constant(true),
> getFileAggregationStrategy()).end();
>
>
>
>
>
> My file is like this
>
>
> 0001 some text here1
> 0001 some text here2
> 0001 some text here3
> 0001 some text here4
> 0001 some text here5
> 0001 some text here6
> 0001 some text here7
> 0002 some text here1
> 0002 some text here2
> 0002 some text here3
> 0002 some text here4
> 0002 some text here5
> 0002 some text here6
> 0002 some text here7
> 0002 some text here8
> 0003 some text here1
> 0003 some text here2
> 0004 some text here3
> 0004 some text here4
> 0004 some text here5
> 0004 some text here6
> 0004 some text here7
> 0004 some text here8
> 0004 some text here8
>
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Split-file-based-on-
> content-tp5794986.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428...@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code=465428=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer=instant_html%21nabble%3Aemail.naml=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context:
http://camel.465427.n5.nabble.com/Split-file-based-on-content-tp5794986p5794988.html
Sent from the Camel - Users mailing list archive at Nabble.com.