Trying to extract data from a JSON

Question:

I’m using tabula-py to extract some data in JSON format and it is returning:
[{'extraction_method': 'stream', 'top': 580.635, 'left': 699.435, 'width': 49.5, 'height': 15.8399658203125, 'right': 748.935, 'bottom': 596.475, 'data': [[{'top': 586.55, 'left': 701.77, 'width': 33.569969177246094, 'height': 4.809999942779541, 'text': '1,227.57'}]]}]

I’m trying to get the data.text attribute which I’m struggling to get to. I’ve tried variations of:
consignment_balance[0]['data']

Looking for a hand as I’m not familiar with Python syntax.

Asked By: aszet

||

Answers:

Read the value from the JSON bit tricky here.

consignment_balance[0]['data'][0][0]['text']
# '1,227.57'

It has a nested list and dictionary so you need to access it accordingly.

Answered By: Rahul K P
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.