Create a markdown table from raw data
The document provides a prompt to format CSV data into a markdown table and includes the output table as well as an API request using the Cohere platform.
This is useful if you want to quickly format a great deal of raw data into a more useful markdown table.
Prompt
You are an expert in data formatting. For the following csv data, output it as a markdown table.
Output the table only.
```
name,age,occupation
Jane Smith,25,Data Scientist
Bob Johnson,42,Software Developer
Emily Davis,37,Product Manager
```Output
| Name | Age | Occupation |
| --- | --- | --- |
| Jane Smith | 25 | Data Scientist |
| Bob Johnson | 42 | Software Developer |
| Emily Davis | 37 | Product Manager |API Request
import cohere
co = cohere.Client(api_key="Your API key")
response = co.chat(
model="command-a-03-2025",
message="""
You are an expert in data formatting. For the following csv data, output it as a markdown table.
Output the table only.
```
name,age,occupation
Jane Smith,25,Data Scientist
Bob Johnson,42,Software Developer
Emily Davis,37,Product Manager
```
""",
)
print(response.text)