Python Forum
How to write to csv file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to write to csv file (/thread-18361.html)



How to write to csv file - SriMekala - May-14-2019

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,


RE: How to write to csv file - buran - May-14-2019

check csv module and in particular csv.DictWriter