Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to write to csv file
#1
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,
Quote
#2
check csv module and in particular csv.DictWriter
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Does python guarantees that file.write() works without file.close() ? kryptomatrix 6 144 Oct-18-2019, 11:44 PM
Last Post: snippsat
  How do I read the HTML files in a directory and write the content into a CSV file? glittergirl 1 108 Sep-23-2019, 11:01 AM
Last Post: Larz60+
  How do I write class objects to a file in binary mode? Exsul1 7 399 Sep-14-2019, 09:33 PM
Last Post: snippsat
  how do i write a cross-platform relative file path? pseudo 2 123 Aug-23-2019, 05:07 PM
Last Post: ThomasL
  write to txt file one line antmar904 3 240 Aug-16-2019, 02:40 PM
Last Post: Axel_Erfurt
  read text file and write into html with correct link jacklee26 4 239 Aug-02-2019, 05:48 AM
Last Post: jacklee26
  is it possible to use python to read and write from a jsx file? nadavrock 3 355 Jun-08-2019, 02:59 AM
Last Post: heiner55
  write image into string format into text file venkat18 2 381 Jun-01-2019, 06:46 AM
Last Post: venkat18
  how can I write my function output on CSV file go127a 13 580 May-05-2019, 01:55 PM
Last Post: go127a
  Python 3.5 streaming output to the same log file that I write to cbj0517 2 370 Apr-23-2019, 04:38 PM
Last Post: cbj0517

Forum Jump:


Users browsing this thread: 1 Guest(s)