remove unnecessary white space, auto detect header, and sorted by name in datagrib from csv file. C# : I know my title is confuse and not clear, now i going to explain what i need.<br/>
In the end of the program, it will be able to input csv file, calculate and output the result.<br/>
For now i m doing it step by step.<br/>
**1)** Able to import csv to datagribview (done)<br/>
**2)** Remove unnecessary white space, sort it by name (in progress) <br/>
**3)** Calculation <br/>
To makes my question clear and easy to understand, here is the csv file sample.
[![enter image description here][1]][1]


As you can see that there are repeated 'lotID' is every section, and 2 type to lotID.

And here is what i have done so far. let's call this pic a.I successfully filter out lotID of the 1st type lotID.
[![enter image description here][2]][2]


this is pic B , as u can see the 'LotID' of section type of lot ID is appear again in each section[![enter image description here][3]][3]


  [1]: https://i.stack.imgur.com/bKSWd.png
  [2]: https://i.stack.imgur.com/LFc7f.png
  [3]: https://i.stack.imgur.com/LCEl1.png
As you can see in PIC A, the lotID of each section is not repeated, and it white space appear in each section.<br/>
This is the first thing i try want to fix.<br/>
Secondly, i want to filter out the 'LotID' header of second type lotid.<br/>
Here is the code.<br/>

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace test2
    {
        public partial class Form1 : Form
        {
            OpenFileDialog openFile = new OpenFileDialog();
    
            public Form1()
            {
                InitializeComponent();
            }
    
    
            private void Button1_Click(object sender, EventArgs e)
            {
                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    List<string[]> rows = File.ReadLines(openFile.FileName).Select(x => x.Split(',')).ToList();
                    DataTable dt = new DataTable();
                    List<string> headerNames = rows[0].ToList();
                    foreach (var headers in rows[0])
                    {
                        dt.Columns.Add(headers);
                    }
                    foreach (var x in rows.Skip(1))
                    {
                        if (x.SequenceEqual(headerNames))   //linq to check if 2 lists are have the same elements (perfect for strings)
                          continue;     //skip the row with repeated headers
                        dt.Rows.Add(x);
                    }
                
                    dataGridView1.DataSource = dt;
                }
            }
    
            private void Form1_Load_1(object sender, EventArgs e)
            {
                openFile.Filter = "CSV|*.csv";
            }
        }
    }
I hope that my question can helps the other if they having same problem like me too! <br/>
Appreciate.