You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by megachucky <me...@googlemail.com> on 2013/12/09 11:38:52 UTC

Which expression language to use within Camel Splitter to split a CSV file?

Here is my use case:

I need to split a CSV file which contains orders. Parsing rules of this CSV
are very simple: 

- Each order has several lines (no fix number)

- Each order begins with one line (initiator): 
111;222;dynamic content

- Each order ends with two lines (terminator)
111;333;dynamic content
111;333;dynamic content

Initiator and terminator have to be included in the outcome of the split.

I am not sure which supported Expression Language
(http://camel.apache.org/expression.html) is best for this kind of use case?
I think this can be solved with a regular expression easily (mabye within a
POJO). What do you think? What is best practice? Thanks for help...

Best regards,
Kai




-----
 Best regards, 
    Kai W&auml;hner 
    
    Twitter: @KaiWaehner 
    Email: kontakt@kai-waehner.de 
    Blog: www.kai-waehner.de/blog 
--
View this message in context: http://camel.465427.n5.nabble.com/Which-expression-language-to-use-within-Camel-Splitter-to-split-a-CSV-file-tp5744503.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Which expression language to use within Camel Splitter to split a CSV file?

Posted by "kraythe ." <kr...@gmail.com>.
Probably best to write a custom data format to handle this. Parse the whole
file into a list records, where each record starts with the data in the
initiator and contains all data up to the next initiator. Writing data
formats is not that tough.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Mon, Dec 9, 2013 at 4:38 AM, megachucky <me...@googlemail.com>wrote:

> Here is my use case:
>
> I need to split a CSV file which contains orders. Parsing rules of this CSV
> are very simple:
>
> - Each order has several lines (no fix number)
>
> - Each order begins with one line (initiator):
> 111;222;dynamic content
>
> - Each order ends with two lines (terminator)
> 111;333;dynamic content
> 111;333;dynamic content
>
> Initiator and terminator have to be included in the outcome of the split.
>
> I am not sure which supported Expression Language
> (http://camel.apache.org/expression.html) is best for this kind of use
> case?
> I think this can be solved with a regular expression easily (mabye within a
> POJO). What do you think? What is best practice? Thanks for help...
>
> Best regards,
> Kai
>
>
>
>
> -----
>  Best regards,
>     Kai W&auml;hner
>
>     Twitter: @KaiWaehner
>     Email: kontakt@kai-waehner.de
>     Blog: www.kai-waehner.de/blog
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Which-expression-language-to-use-within-Camel-Splitter-to-split-a-CSV-file-tp5744503.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Which expression language to use within Camel Splitter to split a CSV file?

Posted by "kraythe ." <kr...@gmail.com>.
Better to write a DataFormat to marshal it and then split the marshaled
records.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Mon, Dec 9, 2013 at 6:47 PM, Christian Posta
<ch...@gmail.com>wrote:

> If you think it can be solved w/ a regex, you can use the simple
> expression language which supports regex
> http://camel.apache.org/simple.html
>
> On Mon, Dec 9, 2013 at 2:38 AM, megachucky <me...@googlemail.com>
> wrote:
> > Here is my use case:
> >
> > I need to split a CSV file which contains orders. Parsing rules of this
> CSV
> > are very simple:
> >
> > - Each order has several lines (no fix number)
> >
> > - Each order begins with one line (initiator):
> > 111;222;dynamic content
> >
> > - Each order ends with two lines (terminator)
> > 111;333;dynamic content
> > 111;333;dynamic content
> >
> > Initiator and terminator have to be included in the outcome of the split.
> >
> > I am not sure which supported Expression Language
> > (http://camel.apache.org/expression.html) is best for this kind of use
> case?
> > I think this can be solved with a regular expression easily (mabye
> within a
> > POJO). What do you think? What is best practice? Thanks for help...
> >
> > Best regards,
> > Kai
> >
> >
> >
> >
> > -----
> >  Best regards,
> >     Kai W&auml;hner
> >
> >     Twitter: @KaiWaehner
> >     Email: kontakt@kai-waehner.de
> >     Blog: www.kai-waehner.de/blog
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Which-expression-language-to-use-within-Camel-Splitter-to-split-a-CSV-file-tp5744503.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Christian Posta
> http://www.christianposta.com/blog
> twitter: @christianposta
>

Re: Which expression language to use within Camel Splitter to split a CSV file?

Posted by Christian Posta <ch...@gmail.com>.
If you think it can be solved w/ a regex, you can use the simple
expression language which supports regex
http://camel.apache.org/simple.html

On Mon, Dec 9, 2013 at 2:38 AM, megachucky <me...@googlemail.com> wrote:
> Here is my use case:
>
> I need to split a CSV file which contains orders. Parsing rules of this CSV
> are very simple:
>
> - Each order has several lines (no fix number)
>
> - Each order begins with one line (initiator):
> 111;222;dynamic content
>
> - Each order ends with two lines (terminator)
> 111;333;dynamic content
> 111;333;dynamic content
>
> Initiator and terminator have to be included in the outcome of the split.
>
> I am not sure which supported Expression Language
> (http://camel.apache.org/expression.html) is best for this kind of use case?
> I think this can be solved with a regular expression easily (mabye within a
> POJO). What do you think? What is best practice? Thanks for help...
>
> Best regards,
> Kai
>
>
>
>
> -----
>  Best regards,
>     Kai W&auml;hner
>
>     Twitter: @KaiWaehner
>     Email: kontakt@kai-waehner.de
>     Blog: www.kai-waehner.de/blog
> --
> View this message in context: http://camel.465427.n5.nabble.com/Which-expression-language-to-use-within-Camel-Splitter-to-split-a-CSV-file-tp5744503.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta