title: Need to convert comma separated data from a file into a list of object
body: <p>I need to read data from a .csv file and store the header and the content in my object in the following format. A list of the below mentioned class.</p>
  
  <pre><code>public class MappingData
  {
      private string ColumnName { get; set; }
      private List&lt;string&gt; Data { get; set; }
  }
  </code></pre>
  
  <p>So for example say I have a table like as shown below, </p>
  
  <pre><code>| Name       | Phone       | City         |
  |:-----------|------------:|:------------:|
  | Yassser    | 32342342234 | Mumbai
  | Sachin     | 32342342234 | Surat    
  | Will       | 32342342234 | London
  </code></pre>
  
  <p>So for the above data my class should have 3 objects, first object will have the following details</p>
  
  <blockquote>
    <p>ColumnName : 'Name'
    Data: ['Yasser', 'Sachin', 'Will']</p>
  </blockquote>
  
  <p>so, this is what I am trying to do, Below is what I have started with. I am reading the file using stream reader and spliting each line with comma seperator.</p>
  
  <pre><code>private List&lt;MappingData&gt; GetData(string filename)
  {
      var data = new List&lt;MappingData&gt;();
      string fullPath = GetFilePath(filename);
      StreamReader reader = new StreamReader(fullPath);
      while (!reader.EndOfStream)
      {
          string line = reader.ReadLine();
          if (!String.IsNullOrWhiteSpace(line))
          {
              string[] values = line.Split(',');
          }
      }
      return data;
  }
  </code></pre>
  
  <p>can some one please help me mold this data into the required format. Thanks.</p>