Home Parse Postgres array to Python list
Reply: 0

Parse Postgres array to Python list

Brylie Christopher Oxley
1#
Brylie Christopher Oxley Published in 2018-01-12 15:50:29Z

I have loaded some data into a pandas dataframe from a CSV file, exported from Postgres. One of the columns comes from a PostgreSQL array field, and looks like so (note that it is a string enclosing the array):

"[
    {"keyOne": "valueOne", "keyTwo": "valueTwo"},
    {"keyOne": "valueOne", "keyTwo": "valueTwo"},
    ...
]"

Note: the object keys are all double quoted. However, not all of the values are double quoted, as some were originally boolean.

How can I parse this into a Python list with the following form:

[
      {"keyOne": "valueOne", "keyTwo": "valueTwo"},
      {"keyOne": "valueOne", "keyTwo": "valueTwo"},
]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30326 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO