labels1 = [{'yMax': u'780.797833935018', 'xMax': u'587.5438596491229', 'xMin': u'366.84210526315786',
'yMin': u'613.9097472924188', 'id': '1', 'name': 'start'},
{'yMax': u'244.37184115523468', 'xMax': u'2096.6666666666665', 'xMin': u'2057.8947368421054',
'yMin': u'125.16606498194946', 'id': '2', 'name': ''},
{'yMax': u'146.02707581227438', 'xMax': u'533.859649122807', 'xMin': u'477.1929824561403',
'yMin': u'119.2057761732852', 'id': u'3', 'name': ''},
{'yMax': u'336.7563176895307', 'xMax': u'838.0701754385965', 'xMin': u'775.438596491228',
'yMin': u'238.4115523465704', 'id': u'4', 'name': ''},
{'yMax': u'235.43140794223828', 'xMax': u'214.73684210526315', 'xMin': u'187.89473684210526',
'yMin': u'149.0072202166065', 'id': u'5', 'name': ''},
{'yMax': u'420.20036101083036', 'xMax': u'456.3157894736842', 'xMin': u'426.49122807017545',
'yMin': u'330.79602888086646', 'id': u'6', 'name': 'end'}
]
My data is a list of dictionaries
as the example shared above just more dictionaries in the list. That example has them hardcoded but in the real situation they're in a txt file, the issue I have is making them work properly read from the txt file in that format.
The data as they look in my .txt file
{'yMax': u'156', 'xMax': u'4802', 'xMin': u'4770','yMin': u'141', 'id': '1', 'name': ''}
{'yMax': u'157', 'xMax': u'4895', 'xMin': u'4810','yMin': u'141', 'id': '2', 'name': ''}
The thing is further processing worked on the hardcoded version but didn't when I read them from a file, because i'm probably reading them as strings
not as dictionaries and not sure what the most efficient way to fix that is, I tried reading them as json.load
or line by line, then using re.findall(r'\d+', str(labels1))
to get the numbers and appending a dict 1 by 1 but it's a hasstle and didn't even work.