Flat file parser routine
<p>We have a flat file.The First five characters on each line determines which type the line belongs to.
Each type has few fields and all are fixed length. How do i go about parsing the file and store it in a database?</p>

<p>Couple of options:</p>

<p>1) Create a XML template for each type and based on the first five characters determine which template to use to parse the line</p>

<p>.</p>

<pre><code>&lt;FileMap&gt;
    &lt;Field Name="FirstName" Start="0" Length="5"/&gt;
    &lt;Field Name="LastName" Start="5" Length="10"/&gt;
    &lt;Field Name="Address" Start="15" Length="15"/&gt;
    &lt;Field Name="City" Start="30" Length="14"/&gt;
    &lt;Field Name="State" Start="44" Length="2"/&gt;
    &lt;Field Name="Zip" Start="46" Length="5"/&gt;
&lt;/FileMap&gt;
</code></pre>

<p>2) Use fileHelpers library (http://filehelpers.sourceforge.net/)</p>

<p>Any other suggestions? Please let me know</p>
