title: Most elegant way to break CSV columns into separate data structures using Python?
body: <p>I'm trying to pick up Python. As part of the learning process I'm porting a project I wrote in Java to Python. I'm at a section now where I have a list of CSV headers of the form:</p>
  
  <pre><code>headers = [a, b, c, d, e, .....]
  </code></pre>
  
  <p>and separate lists of groups that these headers should be broken up into, e.g.:</p>
  
  <pre><code>headers_for_list_a = [b, c, e, ...]
  headers_for_list_b = [a, d, k, ...]
  . . .
  </code></pre>
  
  <p>I want to take the CSV data and turn it into dict's based on these groups, e.g.:</p>
  
  <pre><code>list_a = [
            {b:val_1b, c:val_1c, e:val_1e, ... },
            {b:val_2b, c:val_2c, e:val_2e, ... },
            {b:val_3b, c:val_3c, e:val_3e, ... },
            . . . 
           ]
  </code></pre>
  
  <p>where for example, val_1b is the first row of the 'b' column, val_3c is the third row of the 'c' column, etc. </p>
  
  <p>My first "Java instinct" is to do something like:</p>
  
  <pre><code>for row in data:
      for col_num, val in enumerate(row):
          col_name = headers[col_num]
          if col_name in group_a:
              dict_a[col_name] = val
          elif headers[col_cum] in group_b:
              dict_b[col_name] = val
          ...
      list_a.append(dict_a)
      list_b.append(dict_b)
      ...     
  </code></pre>
  
  <p>However, this method seems inefficient/unwieldy and doesn't posses the elegance that Python programmers are constantly talking about. Is there a more "Zen-like" way I should try- keeping with the philosophy of Python?</p>