Hi folks,
I’m having a few problems setting up a robust DataMapper for the data we’re running through Planet Press. The short version is, the raw data represents invoice information that we’re collating into nicely formatted statements for our customers. The raw data files themselves are reasonably well structured and consistent apart from one area - the end of each record and the end of the report.
Generally speaking, pagination in the raw document is denoted by the FF character. The last four lines in a record vary however, and I need a way of robustly handling the possible scenarios that could exist. Let’s say we have a record with 90 lines. Counting backwards from the very last line:
- Line 90 would contain just the FF character.
- If the customer has requested their statements via email, line 89 will contain the text “#email” to denote they are an email customer (which we then use elsewhere in the DataMapper), OTHERWISE, line 89 contains the totals for their statement.
- If the customer has requested their statements via email, then line 88 will contain the totals for their statement.
As a final wrinkle to this, if the record is the last one in the document, there will be no final FF character, the document just ends. So, in this instance, the last line would contain either the “#email” text or their totals for the statement.
Sorry that this is a bit of a big ask, but I’m really struggling to get my head around how to build a robust process in DataMapper that can handle any of those scenarios. I did wonder if it might be possible to tell it to look for the last row in a record that contains numeric data, assume that those are the totals and go from there, but even then I’m not sure how best to implement that.
If anyone is able to suggest how I could approach this I’d be most grateful.
All the best,
Rich