title: Changing a csv file, reading and writing with dynamic mapping
body: <p>Assume I have a large csv file that I'd like to read, modify and write back. Perhaps I want to change a field separator from comma to tab. Perhaps I want to change the quotation character from ' to ". Or may be I want to add a plus sign to each value in the first column. Since the file is large, I do not want to load it in memory all at once, I'd like to read it record by record.</p>
  
  <p>So I write a code like this:</p>
  
  <pre><code>var inPath = @"infile.txt";
  var outPath = @"outfile.txt";
  
  CsvConfiguration readCf = GetReadConfiguration();
  CsvConfiguration writeCf = GetWriteConfiguration();
  
  using (var streamin = new FileStream(inPath, FileMode.Open))
  using (var streamReader = new StreamReader(streamin))
  {
      using (var csvReader = new CsvReader(streamReader, readCf))
      using (var csvWriter = new CsvWriter(new StreamWriter(outPath), writeCf))
      {
          while (csvReader.Read())
          {
              var currentRecord = csvReader.GetRecord&lt;dynamic&gt;();
              UpdateRecord(currentRecord);
              csvWriter.WriteRecord(currentRecord);
          }
      }
  }
  </code></pre>
  
  <p>This fails at run time with the following error:</p>
  
  <blockquote>
    <p>Types that inherit IEnumerable cannot be auto mapped. Did you
    accidentally call GetRecord or WriteRecord which acts on a single
    record instead of calling GetRecords or WriteRecords which acts on a
    list of records?</p>
  </blockquote>
  
  <p>Note, that nothing interesting happens in <code>UpdateRecord</code>, in fact this line above can be completely commented out.</p>
  
  <p>What happens is that <code>GetRecord</code> returns an <code>ExpandoObject</code> and then <code>WriteRecord</code> chokes on this object.</p>
  
  <p>What is the best way to make this work?</p>
  
  <p><strong>Update</strong>
  Just so it's clear: I fully realize that I'm getting this error is because <a href="https://github.com/JoshClose/CsvHelper" rel="nofollow noreferrer">CSVHelper</a> does not support <code>ExpandoObject</code>s for <code>WriteRecord</code> call. I'm looking for suggestions, for easiest way to make this work.</p>