title: C# read csv, calculate something, export another csv
body: <p>I am new to C#. I would like to know how I can do the following computations in an intuitive way in C#. How should I read the input csv file to facilitate the required computations? Do I read the csv into lists, arrays, datatable, etc.? There are null values in some cells. Since I am really new to C#, it is greatly appreciated if you could provide some examples. Thank you. :)</p>
  
  <p><strong>Input:</strong> 
  I have an input csv file with format:</p>
  
  <pre><code>&lt;p&gt; // header: date, Y, X1, X2, X3, X4 &lt;/p&gt;
  &lt;p&gt; // value: yyyy-mm-dd, double, double, double, double, double &lt;/p&gt;
  </code></pre>
  
  <p>So I have time series data of Y and all the X's. For each distinct date, I have many rows of Y and X's.</p>
  
  <p><strong>Data processing:</strong>
  I would like to do the followings:</p>
  
  <ol>
  <li><p>For each distinct date, compute correlations between Y and each X. The length of Y and X can differ in distinct date. So I will have corr(Y, X1), corr(Y, X2), corr(Y,X3) , corr(Y,X4) for each date.</p></li>
  <li><p>For each distinct date, sort Y and get the rank of each row, e.g.</p></li>
  </ol>
  
  <p> Y rank <br />
  
       10 1 <br />
       50 4 <br />
       20 2 <br />
       30 3 </p>
  
  <p>After obtaining the ranks, they are used to compute a single quantity, say QUANTITY. (Each distinct date I will have one number of QUANTITY.) </p>
  
  <p><strong>Output:</strong>
  After all the computations, I would like to export the results to another csv file with format:</p>
  
  <pre><code>&lt;p&gt; // header: date, corr(Y, X1), corr(Y, X2), corr(Y,X3), corr(Y,X4), QUANTITY &lt;/p&gt;
  &lt;p&gt; // value: yyyy-mm-dd, double, double, double, double, double &lt;/p&gt;
  </code></pre>