title: how to remove spaces and identify multiple spaces and place them in a table data from text file?
body: <p>i have huge text tables in a text file and i am able to read data inside my winform application but there is some irregular data coming inside the datagrid. i just needed the table as it is, into my datagrid. i want to catch "*( 3)" from the data and using that number i want to split the data below. The Plate Id column can have n number of Id's. So according to that Plate Id's X-coord and Y-coord's will be added to them. how to place this table data inside a datagrid without disturbing it's structure? I need to re-use this data from datagrid again.</p>
  
  <pre><code>*( 3)CAR PLATE COORDINATES:
  *  No.   Plate  Plate   No.   X-Coord   Y-Coord
  * Plate  Type    Id    Coord    (in)      (in)
      2    'CA'     1      5     8.6250  -23.3750
                                32.6249  -23.3750
                                46.5983  120.6250
                                46.5983  120.6250
                                 8.6250  120.6250
           'CA'     2      5     8.6250  120.6250
                                46.5983  120.6250
                                64.6250  306.3959
                                59.3717  369.4359
                                 8.6250  365.2070
           'CA'     3      5     8.6250  120.6250
                                46.5983  120.6250
                                64.6250  306.3959
                                59.3717  369.4359
                                 8.6250  365.2070
  </code></pre>
  
  <hr>
  
  <pre><code>lbl2.Text = fdlg.FileName;
                  IEnumerable&lt;String&gt; lines = File.ReadLines(lbl2.Text);
                  if (lines.Count() &gt; 0 &amp;&amp; lines.Contains("*( 3)"))
                  {
  
                      foreach (var columnName in lines.FirstOrDefault().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
                      {
                          dataGridView3.Columns.Add(columnName, columnName);
                              while (lines.Contains(null))
                                  break;
  
  
                          foreach (var cellValues in lines.Skip(1))
                          {
                              var cellArray = cellValues.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                      while (lines.Contains("*("))
                          {
                      foreach (var columnName in lines.FirstOrDefault()
                          .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))                       
                              dataGridView3.Columns.Add(columnName, columnName);
                          }
                  }
  
             }  
  }
  </code></pre>