title: What is the pythonic way to read CSV file data as rows of namedtuples?
body: <p>What is the best way to take a data file that contains a header row and read this row into a named tuple so that the data rows can be accessed by header name?</p>
  
  <p>I was attempting something like this:</p>
  
  <pre><code>import csv
  from collections import namedtuple
  
  with open('data_file.txt', mode="r") as infile:
      reader = csv.reader(infile)
      Data = namedtuple("Data", ", ".join(i for i in reader[0]))
      next(reader)
      for row in reader:
          data = Data(*row)
  </code></pre>
  
  <p>The reader object is not subscriptable, so the above code throws a <code>TypeError</code>. What is the pythonic way to reader a file header into a namedtuple?</p>