title: Trying Populate DataGridView or DataTable from a CSV, which is an embedded resource
body: <p>Well, been trying to do this for some time now and have been searching through loads of sites for a clue but no luck. </p>
  
  <p>I am trying to populate either a DataTable or a DataGridView with a comma delimited CSV I have added as a resource (drag-drop on vb.net-2013 resource window). </p>
  
  <p>I have managed to get the DataGridView columns to show the first line from CSV, not the rest though. CSV looks like: </p>
  
  <pre><code>"id,city,loc,lat,lon,chk,tst,sob,completed,1,charlotte,dock,0000.0,0000.0,,,,,,2,Chicago,..." 
  </code></pre>
  
  <p>Whenever I try populating the rows I get an error:</p>
  
  <pre><code>    Input array is longer than the number of columns in this table.
  </code></pre>
  
  <p>There are 9 columns and about 700k rows, first row is col names.</p>
  
  <p>Thanks for any help.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>        Dim tbl = New DataTable
          Dim lines() As String = My.Resources.CityLocation.Split(CChar(Environment.NewLine))
          Dim colCount = lines.First.Split(","c).Length
          Dim col = Split(lines(0), ","c)
          Dim rowCount = lines.GetLength(0)
  
          'Populating the Column Headers
          For i = 0 To colCount - 1
              tbl.Columns.Add(New DataColumn(col(i), GetType(String)))
          Next
  
          ''Populating the Rows
          'For i = 1 To rowCount
          '    For Each line In lines
          '        Dim theRow = From field In line.Split(","c)
          '        Dim Array() = theRow.ToArray
          '        Dim newRow = tbl.Rows.Add()
          '        newRow.ItemArray = Array
          '    Next
          'Next
  </code></pre>
  
  <p>`</p>