Python Quickstart
With just a few lines of code, your python application can convert CSV and JSON data to awesome plain-text tables.
Info
These examples are all written for Python 3.
Examples
import csv
import io
import json
import requests
csvdata = [
["Pokemon","Type","Number"],
["Venusaur","Grass",3],
["Charizard","Fire",6],
["Blastoise","Water",9],
["Pikachu","Electric",25]
]
output = io.StringIO()
writer = csv.writer(output)
writer.writerows(csvdata)
url = "https://mkconvert.p.rapidapi.com/table?table-tablefmt=github"
headers = {
"Content-Type": "text/plain",
"X-RapidAPI-Host": "mkconvert.p.rapidapi.com",
"X-RapidAPI-Key": "<rapid api key>"
}
response = requests.request("POST", url, data=output.getvalue(), headers=headers)
print(json.loads(response.text)["data"])
# Output
| Pokemon | Type | Number |
|-----------|----------|----------|
| Venusaur | Grass | 3 |
| Charizard | Fire | 6 |
| Blastoise | Water | 9 |
| Pikachu | Electric | 25 |
import json
import requests
data = [
{
"Pokemon": "Venusaur",
"Type": "Grass",
"Number": 3
},
{
"Pokemon": "Charizard",
"Type": "Fire",
"Number": 6
},
{
"Pokemon": "Blastoise",
"Type": "Water",
"Number": 9
},
{
"Pokemon": "Pikachu",
"Type": "Electric",
"Number": 25
}
]
url = "https://mkconvert.p.rapidapi.com/table?table-tablefmt=github"
headers = {
"Content-Type": "application/json",
"X-RapidAPI-Host": "mkconvert.p.rapidapi.com",
"X-RapidAPI-Key": "<rapid api key>"
}
response = requests.request("POST", url, data=json.dumps(data), headers=headers)
print(json.loads(response.text)["data"])
# Output
| Pokemon | Type | Number |
|-----------|----------|----------|
| Venusaur | Grass | 3 |
| Charizard | Fire | 6 |
| Blastoise | Water | 9 |
| Pikachu | Electric | 25 |
Next Steps
Dive into the API Reference to view all available options.