title: Convert reading of delimited file from F# to C#
body: <p>I know this is a rather thick question but I am attempting to perform some comparisons between F# and C# and have borrowed an F# script from <a href="http://www.clear-lines.com/blog/post/Nearest-Neighbor-Classification-part-2.aspx" rel="nofollow">http://www.clear-lines.com/blog/post/Nearest-Neighbor-Classification-part-2.aspx</a> and am trying to get the equivilant operation out of a C# program for the purpose of testing operation and syntax. This part is in a larger script that I am converting to an F# program that performs a k-means analysis of given data.</p>
  
  <p>Here is the F# portion:</p>
  
  <pre><code>let elections =
      let file = @"C:\Users\Deines\Documents\Election2008.txt"
      let fileAsLines =
          File.ReadAllLines(file)
              |&gt; Array.map (fun line -&gt; line.Split(','))
      let dataset =
          fileAsLines
          |&gt; Array.map (fun line -&gt;
              [| Convert.ToDouble(line.[1]);
                 Convert.ToDouble(line.[2]);
                 Convert.ToDouble(line.[3]) |])
      let labels = fileAsLines |&gt; Array.map (fun line -&gt; line.[4])
      dataset, labels 
  </code></pre>
  
  <p>Here is a sample of the data (Election2008.txt):</p>
  
  <pre><code>AL,32.7990,-86.8073,4447100,REP 
  AK,61.3850,-152.2683,626932,REP 
  AZ,33.7712,-111.3877,5130632,REP 
  AR,34.9513,-92.3809,2673400,REP 
  CA,36.1700,-119.7462,33871648,DEM 
  CO,39.0646,-105.3272,4301261,DEM 
  CT,41.5834,-72.7622,3405565,DEM 
  DE,39.3498,-75.5148,783600,DEM 
  DC,38.8964,-77.0262,572059,DEM 
  FL,27.8333,-81.7170,15982378,DEM 
  </code></pre>