Import text file into csv file

Question:

I am new in Python and looking to change text data in csv data, where column contains id, sequence, createdAt, and createdBy?

Text File

[{"id":1,"sequence":14,"createdAt":"2021-03-04xx:x:x","createdBy":"xxxxxxxxxxxx"}},

{"id":2,"sequence":14,"createdAt":"2021-03-04Txx:x:x","createdBy":"xxxxxxxxxxxx"}},

{"id":3,"sequence":14,"createdAt":"2021-03-04Txx:x:x","createdBy":"xxxxxxxxxxxx"}}]

Asked By: dtc348

||

Answers:

Input Data Set appears to be JSON structure
I’d recommend csvkit https://csvkit.readthedocs.io/en/latest/index.html

Specifically , module in2csv – very powerful

Alternatively – use pandas read_json – this will enable you load into a DataFrame

Answered By: irnerd
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.