I have written code to read a CSV into a python dictionary, which works fine. I\'m trying to get the dictionary back to a CSV. I have written the following:
Sample data:
mydict = [{"col1": 1000, "col2": 2000}, {"col1": 3000, "col2": 4000}]
One-liner for converting a list of dicts to CSV, using pandas:
import pandas as pd pd.DataFrame(mydict).to_csv('out.csv', index=False)
Results:
col1,col2 1000,2000 3000,4000