title: Converting responses returned from REST API into CSV
body: <p>I am trying to write response returned from REST API into a csv file. As there are multiple requests, I am calling API on the requests one by one. So, there would be multiple responses. I am not able to achieve desired format.</p>
  
  <p><strong><em>Desired format :</em></strong></p>
  
  <pre><code>name,job,id,createdAt
  morpheus,leader,727,2018-10-12T12:04:39.234Z
  Mark,SSE,925,2018-10-12T12:04:40.200Z
  Taylor,SE,247,2018-10-12T12:04:41.115Z
  </code></pre>
  
  <p><strong><em>Code :</em></strong> </p>
  
  <pre><code>import requests
  
  url ='https://reqres.in/api/users'
  data =[{
      "name": "morpheus",
      "job": "leader"
  },
      {"name":"Mark",
      "job":"SSE"},
  
      {"name":"Taylor",
      "job":"SE"}
  ]
  
  with open('response.csv','w') as f:
      for element in data:
          r=requests.post(url,json=element)
          response = json.loads(r.text)
          for key in response.keys():
              #f.write("%s,%s"%(key,response[key]))
  </code></pre>