title: How to save API response to csv with Python
body: <p>I'm getting facedetection data from an API in this form:</p>
  <pre><code>{&quot;id&quot;:1,&quot;ageMin&quot;:0,&quot;ageMax&quot;:100,&quot;faceConfidence&quot;:66.72220611572266,&quot;emotion&quot;:&quot;ANGRY&quot;,&quot;emotionConfidence&quot;:50.0'
  b'2540969848633,&quot;eyeglasses&quot;:false,&quot;eyeglassesConfidence&quot;:50.38102722167969,&quot;eyesOpen&quot;:true,&quot;eyesOpenConfidence&quot;:50.20328140258789'
  b',&quot;gender&quot;:&quot;Male&quot;,&quot;genderConfidence&quot;:50.462989807128906,&quot;smile&quot;:false,&quot;smileConfidence&quot;:50.15522384643555,&quot;sunglasses&quot;:false,&quot;sun'
  b'glassesConfidence&quot;:50.446510314941406}]'
  </code></pre>
  <p>I'd like to save this to a csv-file like this:</p>
  <pre><code>id  ageMin  ageMax  faceConfidence
  1   0       100     66
  </code></pre>
  <p>... and so on.
  I tried to do it this way:</p>
  <pre><code>response = requests.get(url, headers=headers)
      with open('detections.csv', 'w') as f:
          writer = csv.writer(f)
          for item in response:
              writer.writerow(str(item))
  </code></pre>
  <p>That puts every char in its own cell. I've also tried to use <code>item.id</code>, but that gives an error: <code>AttributeError: 'bytes' object has no attribute 'id'</code>.</p>
  <p>Could someone point me to the right direction?</p>