improvdev
improvdev

Reputation: 21

Camel CSVRecord Camel Bindy

I'm using camel with bindy (2.16.0) to parse a csv file. The file contains a header and a footer. Both are used as metadata to describe common data for all other records. (Customer defined so I cant change the CSV Format)

Im using Bindy to parse the data for me. The issue that I'm having is that for CSVRecord you cannot exclude the footer. I'm able to skip the header but the parsing of the data fails because it cannot parse the footer since the data format is different.

Is there a way to exclude the last line/footer from CSVRecord bindy or maybe have camel read and remove the last line in another way?

Upvotes: 2

Views: 1785

Answers (2)

Espresso
Espresso

Reputation: 5739

You can consider an alternate solution:

  • Take the csv from customer
  • preprocess csv through a cleanup step: parse header/fooder and get it out of the way. But collect the common parameters so you can enrich other objects.
  • Parse the rest of the "clean csv" through bindy, and then enrich with header/footer common

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55540

No this is currently not supported in bindy. Is the footer in your case a single line only? Or does it have any special leading marker to indicate its a footer?

We could maybe improve bindy to support skipping footer. So maybe a footer by default is just the last line. But just wonder if people may have multiple lines as footer?

You would need to manually remove that last line yourself before parsing it with bindy. If the file is not big, and you can have it in memory you can use a Camel processor / bean and remove the last line from the message body.

Upvotes: 1

Related Questions