You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Guillermo <gl...@tecsisa.com> on 2013/04/30 11:02:03 UTC

Best strategy for skipping lines in CSV files with bindy

Hi,

I'm using the library Bindy for parsing files and I recently found a
problem. Let me explain:

I read in the camel docs that I can skip the first line of the CSV, but what
is the correct way to skip more than one line? Three lines at the beginning
of the file in my case and two at the end of the file. The file looks like
this:

unimportant info;unimportant info;unimportant info
unimportant info
unimportant info;unimportant info
relevant info;relevant info;relevant info;relevant info
[...]
relevant info;relevant info;relevant info;relevant info
;;unimportant info;unimportant info;;;unimportant info;unimportant
info;unimportant info;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;

Where "relevant info" has the same format for all rows and is the data that
I need to parse with my csv record definition.

Is there any way to skip the lines automatically? What is the best strategy
to do that?

Thanks in advance.

Guillermo.

Additional info:
Using camel version 2.9.4




--
View this message in context: http://camel.465427.n5.nabble.com/Best-strategy-for-skipping-lines-in-CSV-files-with-bindy-tp5731784.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: AW: Best strategy for skipping lines in CSV files with bindy

Posted by Guillermo <gl...@tecsisa.com>.
Thanks for the reply!

I will think about which of the two forms is the best for me.

Regards.



--
View this message in context: http://camel.465427.n5.nabble.com/Best-strategy-for-skipping-lines-in-CSV-files-with-bindy-tp5731784p5732190.html
Sent from the Camel - Users mailing list archive at Nabble.com.

AW: Best strategy for skipping lines in CSV files with bindy

Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
> Finally I have created a processor with a BufferedReader to filter the
> lines of the file according to a regular expression, so I get the file
> as String only with the important lines. Later, I use bindy as usual.

Instead of reading the file by myself using a BufferedReader I would check
the line content inside the route, something like

from("file:data.csv")
    // http://camel.apache.org/splitter.html
    .split().tokenize("\n")
    .choice()
        // http://camel.apache.org/simple.html
        .when(simple("$body regex ..."))
            // http://camel.apache.org/bindy.html
            .marshal().bindy(BindyType.Csv, "my.pack.age.with.data.model")
            .to("direct:process")
        .otherwise()
            .to("direct:ignore")


Jan


Re: Best strategy for skipping lines in CSV files with bindy

Posted by Guillermo <gl...@tecsisa.com>.
Hi,

Finally I have created a processor with a BufferedReader to filter the lines
of the file according to a regular expression, so I get the file as String
only with the important lines. Later, I use bindy as usual.

Regards.

Guillermo.



--
View this message in context: http://camel.465427.n5.nabble.com/Best-strategy-for-skipping-lines-in-CSV-files-with-bindy-tp5731784p5732149.html
Sent from the Camel - Users mailing list archive at Nabble.com.