0

I am trying to extract data from hundreds of text strings that have the following structure:

[{
    "x": 63.43947250969682,
    "y": 88.9877012738793,
    "id": 281281,
    "p": "S.Jones",
    "h": false,
    "t": "SYD",
    "ts": 52,
    "qt": "Q1-0:52",
    "sp": 6,
    "g": false,
    "b": false,
    "rb": false,
    "d": "First Possession",
    "di": 70,
    "a": 25
}, {
    "x": 60.321184902496682,
    "y": 89.602683737848977,
    "id": 290778,
    "p": "L.Parker",
    "h": false,
    "t": "SYD",
    "ts": 53,
    "qt": "Q1-0:53",
    "sp": 3,
    "g": false,
    "b": false,
    "rb": false,
    "d": "Effective Pass",
    "di": 68,
    "a": 27
}]

Clearly, the square brackets are used to group collections of elements, the curly brackets {} sub-collections and the field titles are given in quotes, e.g. "x", with their result separated by ":". I am using python and have tried BeautifulSoup, but given the structure is not really typical html, I can't seem to get it working.

What is the best way to parse this? Are there any good packages that I can leverage to extract the data? Grateful for any suggestions here!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
user3725021
  • 566
  • 3
  • 14
  • 32

0 Answers0