I have deployed my personality insights service App in Bluemix and I could invoke post command to send the text. I want to save the output of a data to csv, i had gone through the API documentation of Personality API, however i could not understand where i am going wrong. Can any one help me in storing the output to csv file.
Here is the code i have used in Python.
#!/usr/bin/env python
# coding: utf-8
import requests
import json
import csv
response = requests.post("https://gateway.watsonplatform.net/personality-insights/api/v2/profile",
auth=("user-id", "password"),
headers={"content-type": "application/json", "Accept": "text/csv"},
data = "text to be analyzed"
)
jsonProfile = json.loads(response.text)
with open('test1234.csv', 'w') as f:
for row in jsonProfile:
f.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
Please help me on this.