title: How to write only selected class fields into CSV with CsvHelper?
body: <p>I use <a href="https://github.com/JoshClose/CsvHelper"><code>CsvHelper</code></a> to read and write CSV files and it is great, yet I don't understand how to write only selected type fields.</p>
  
  <p>Say we had:</p>
  
  <pre><code>using CsvHelper.Configuration;
  
  namespace Project
  {
      public class DataView
      {
          [CsvField(Name = "N")]
          public string ElementId { get; private set; }
  
          [CsvField(Name = "Quantity")]
          public double ResultQuantity { get; private set; }
  
          public DataView(string id, double result)
          {
              ElementId = id;
              ResultQuantity = result;
          }
      }
  }
  </code></pre>
  
  <p>and we wanted to exclude "Quantity" <code>CsvField</code> from resulting CSV file that we currently generate via something like:</p>
  
  <pre><code>using (var myStream = saveFileDialog1.OpenFile())
  {
      using (var writer = new CsvWriter(new StreamWriter(myStream)))
      {
          writer.Configuration.Delimiter = '\t';
          writer.WriteHeader(typeof(ResultView));
          _researchResults.ForEach(writer.WriteRecord);
      }
  }
  </code></pre>
  
  <p>What could I use to dynamically exclude a type field from the CSV?</p>
  
  <p>If it is necessary we could process the resulting file, yet I do not know how to remove an entire CSV column with <code>CsvHelper</code>.</p>