Python Forum

Full Version: How to write to csv file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I read some data from the web which is in the below format:

[{'expTime":"2019\/04\/02 00:11:23","type_exp" :"INJ_2026","F_pair":148,"end_count":3,"rank":96},{'expTime":"2019\/04\/05 13:20:12,"type_exp" :"INJ_2056","F_pair":48,"end_count":8,"rank":36},{'expTime":"2019\/04\/12 20:13:23","type_exp" :"INJ_2045","F_pair":68,"end_count":2,"rank":66}]

Now I want to write it to CSV file as below:

expTime               type_exp   F_pair end_count rank
2019/04/02 00:11:23   INJ_2026     148    3         96
2019/04/05 13:20:12   INJ_2056     48     8         36
2019/04/12 20:13:23   INJ_2045     68     2         66
Please help someone,
check csv module and in particular csv.DictWriter