title: Convert JSON to CSV
body: <p>In python I have a complex object hierarchy made of lists and dictionaries. I want to spit it all out to CSV or some other kind of database format. Any answers in Python or Javascript very much appreciated.</p>
  
  <p>I understand that one CSV file (or table) can only represent one 'level' of object in my hierarchy, so the solution would need to create multiple files.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>{
      "Person" : [{"name":"Greg","age":"35","car":["honda civic","ford focus"]},
                  {"name":"Steve","age":"28", "car":["mazda 323", "toyota camry"]}]
  }
  </code></pre>
  
  <p>would become </p>
  
  <pre><code>Person.csv:
  id,name,age
  1,Greg,35
  2,Steve,28
  
  car.csv:
  id,Person_id,value
  1,1,honda civic
  2,1,ford focus
  3,2,mazda 323
  4,2,toyota camry
  </code></pre>
  
  <p>Basically the only thing interesting going on here is the assignment of new ids so that the rows in the tables can be associated.</p>
  
  <p>Cheers,
  Dave</p>