Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python, create dataframe from data dump

We pull some data from a URL. The data comes down as one huge string, but within it is delimited into small lists / pairs. A small sample of the data is here:

[{"date_of_fix ":"9\/4\/2023","fix_description":"Broken report links\r","issue_no ":"1788"},{"date_of_fix ":"8\/30\/2023","fix_description":"Icon on password fields","issue_no ":"1769"},{"date_of_fix ":"8\/21\/2023","fix_description":"Add Tracking to Quote Page\r","issue_no ":"1744"}]

Would like to convert this to a dataframe, so I can later insert it into Oracle. But it is coming down as one huge delimited string, so not sure how to loop / split / convert / append this onto a dataframe.

Any help would be awesome.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks!

>Solution :

If you are getting such string with three items in each, you can use pandas read_json() function for this.

import pandas as pd
received_str = '[{"date_of_fix ":"9\/4\/2023","fix_description":"Broken report links\r","issue_no ":"1788"},{"date_of_fix ":"8\/30\/2023","fix_description":"Icon on password fields","issue_no ":"1769"},{"date_of_fix ":"8\/21\/2023","fix_description":"Add Tracking to Quote Page\r","issue_no ":"1744"}]'
df = pd.read_json(received_str)

The resulting dataframe (df) should have three columns.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading