title: Parsing a multi-line fixed format text file
body: <p>I'm trying to parse some data in a fixed format text file where each "record" is spread over a number of lines, as so ...</p>
  
  <pre><code> MAILBOX: 10013      Created: 01/20/09  4:39 pm
      MSGS: 0         UNPLAYED: 0           URGENT: 0          RECEIPT: 0
    LCOS: RBC Standard    : 20            FCOS: RBC Standard      : 20 
    GCOS: Default GCOS 1  : 1             NCOS: Default           : 1 
    TCOS: Default TCOS 1  : 1             RCOS:                   : 1 
  BAD LOGS: 0         LAST LOG: NEVER                             MINS:      0.0
    PASSWD: Y            TUTOR: N              DAY: M            NIGHT: M       
      NAME:                                   CODE: 
     EXTEN: 10013                            INDEX: 0
  ATTEN DN:                                  INDEX: 0         
  DISTRIBUTION LISTS WITH CHANGE RIGHTS:
      all
  DISTRIBUTION LISTS WITH REVIEW RIGHTS:
      all
  </code></pre>
  
  <p>I've used <a href="http://www.filehelpers.com/">File Helpers</a> before for single line records, and it's been very useful. Checking it's documentation, it does have a <code>MultiRecordEngine</code> feature, but this is going to mean ...</p>
  
  <ul>
  <li>a class for each line ... <em>not a problem</em></li>
  <li>calculating the exact size of each fixed format field ... <em>painful and open to error</em></li>
  <li>logic to check each line </li>
  </ul>
  
  <p>And a further wrinkle I found was the <em>fixed format</em> is actually <em>not fixed</em>, i.e. there are different format lines depending on the target record, so some have 21 lines, some 22, 23, 24, etc. </p>
  
  <p>I have found a Java flat file parsing library, <a href="http://jffp.sourceforge.net/">FFP</a>, but I'm a .NET, C#, PowerShell coder</p>
  
  <p>Are there better ways of handling this sort of parsing ?</p>