title: Convert JSON to CSV using Python (Idle)
body: <p>I have a JSON file of Latitude/Longitude that I want to covert to a CSV file. I want to do this using Python. I have read/tried all other stackoverflow and google search results suggestions. I've managed to get as far as creating the CSV and including headers, but beyond that, goofy stuff starts to happen. Here is the working part of my code so far:</p>
  
  <pre><code>import json, csv
  
  x="""[
      {"longitude":"-73.689070","latitude":"40.718000"},
      {"longitude":"-73.688400","latitude":"40.715990"},
      {"longitude":"-73.688340","latitude":"40.715790"},
      {"longitude":"-73.688370","latitude":"40.715500"},
      {"longitude":"-73.688490","latitude":"40.715030"},
      {"longitude":"-73.688810","latitude":"40.714370"},
      {"longitude":"-73.688980","latitude":"40.714080"},
      {"longitude":"-73.689350","latitude":"40.713390"},
      {"longitude":"-73.689530","latitude":"40.712800"},
      {"longitude":"-73.689740","latitude":"40.712050"},
      {"longitude":"-73.689820","latitude":"40.711810"},
      {"longitude":"-73.689930","latitude":"40.711380"},
      {"longitude":"-73.690110","latitude":"40.710710"}
  ]"""
  
  x = json.loads(x)
  
  f = csv.writer(open("test.csv", "wb+"))
  
  f.writerow(["longitude", "latitude"])
  </code></pre>
  
  <p>And here's where it falls apart ("?'s" mean I'm not sure what to put there. I've tried all sorts of combinations of things that I've found in my search for answers):</p>
  
  <pre><code>for ? in ?:
      f.writerow([?[?],?[?]])
  </code></pre>
  
  <p>I got the above from answers to <a href="https://stackoverflow.com/questions/1871524/convert-from-json-to-csv-using-python">this question</a> by <a href="https://stackoverflow.com/users/227684/little-fish">little_fish</a>. I can see that our JSON examples are slightly different, and I am assuming that has something to do with why I can't get it to work... </p>
  
  <p>Any help would be greatly appreciated, and I am happy to provide clarification if need be. FYI, I am new to Python, so if you're going to use jargon, please explain it as clearly as possible. Thanks! (P.S. Not sure if it matters, but I am using IDLE).</p>