Create CSV data from JSON data
Easily convert one data format to another. This applies not only to json or csv formats but many widely used data formats.
Prompt
Output
API Request
PYTHON
Create CSV data from JSON data
Easily convert one data format to another. This applies not only to json or csv formats but many widely used data formats.
Prompt
You are an expert in data formatting. Convert the following JSON object into CSV format. ``` [ { "name": "Jane Smith", "age": 25, "occupation": "Data Scientist" }, { "name": "Bob Johnson", "age": 42, "occupation": "Software Developer" }, { "name": "Emily Davis", "age": 37, "occupation": "Product Manager" }, ] ```
Output
name,age,occupation Jane Smith,25,Data Scientist Bob Johnson,42,Software Developer Emily Davis,37,Product Manager
API Request
1 import cohere 2 3 co = cohere.Client(api_key='Your API key') 4 response = co.chat( 5 message=""" 6 You are an expert in data formatting. Convert the following JSON object into a CSV format. 7 8 ``` 9 [ 10 { 11 "name": "Jane Smith", 12 "age": 25, 13 "occupation": "Data Scientist" 14 }, 15 { 16 "name": "Bob Johnson", 17 "age": 42, 18 "occupation": "Software Developer" 19 }, 20 { 21 "name": "Emily Davis", 22 "age": 37, 23 "occupation": "Product Manager" 24 }, 25 ] 26 ``` 27 """, 28 ) 29 print(response)