title: How do I copy certain rows from a csv file into a new file using C#?
body: <p>I am using C# to make a small application that automates some manual processes. I have a CSV file, I must search the second column (which has the name "Status"), if the status is "clear" then I do not need this row, else I need to copy this row into another file and save the aggregated file. Additionally, I would also like to know how to delete (automatically) certain columns of a csv file in c#. Here is what I have thus far: (The first button is "Show Original" while the second is "Alter and Save"</p>
  
  <pre><code>namespace AppExcel
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
  
      }
  
      private static List&lt;string[]&gt; ReadAndParseData(string path, char separator )
      {
          var parsedData = new List&lt;string[]&gt;();
          using (var sr = new StreamReader(path))
          {
              string line;
              while ((line = sr.ReadLine()) != null)
              {
                  string[] row = line.Split(separator);
                  string[] column = line.Split('\n');
                  parsedData.Add(row);
              }
  
          }
          return parsedData;
      }
  
      private void DrawGridView(List&lt;string[]&gt; parsedData)
      {
  
          dataGridView1.ColumnCount = 47;
          for (int i = 0; i &lt; 47; i++)
          {
              var sb = new StringBuilder(parsedData[0][i]);
              sb.Replace('_', ' ');
              sb.Replace("\"", "");
              dataGridView1.Columns[i].Name = sb.ToString();
  
  
          }
  
          foreach (string[] row in parsedData)
          {
              dataGridView1.Rows.Add(row);
  
          }
  
          dataGridView1.Rows.Remove(dataGridView1.Rows[0]);
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          List&lt;string[]&gt; parsedData = ReadAndParseData(@"C:/Export Data.csv", ',');
  
  
          DrawGridView(parsedData);
      }
  
      private void button2_Click(object sender, EventArgs e)
      {
          List&lt;string[]&gt; parsedData = ReadAndParseData(@"C:/Export Data.csv", ',');
          foreach (string[] row in parsedData)
          {
              if (row != parsedData[0])
              { 
                // What to insert here??
  
              }
          }
  
      }
  
      private void button3_Click(object sender, EventArgs e)
      {
  
      }
  }
  }
  </code></pre>