title: Adding a column to dictReader without modifying the CSV file
body: <p>I have a CSV file that has 3 columns. Let's say: <code>a</code>, <code>b</code>, <code>c</code>. I'm using <code>csv.dictReader</code> to read it and add another column that has just the name of the file on each row. </p>
  
  <p>This is my function:</p>
  
  <pre><code>def addFilename(self):
      with open(self.datafile, "r") as f:
          reader = csv.DictReader(f, delimiter='|')
          for a, b, c in reader:
              #Get filename
              filename = self.getFilename()
              yield {
                  "_source": {
                      "a": a,
                      "b": b,
                      "c": c,
                      "filename": filename
                  }
              }
  </code></pre>
  
  <p>Now I'd like to generalize that behavior for many different CSV files. Those files have different number of columns and different column names. Is there a way to do so?</p>
  
  <p>I don't want to modify the CSV file. The only thing I know is that I can get the fieldnames (and the number of fields) using <code>reader.fieldnames</code>, but I don't know how I could use that in a <code>yield</code>.</p>