I have a string like below:
[Base Font : IOHLGA+Trebuchet, Font Size : 3.5324998, Font Weight : 0.0] [(X=250.44,Y=223.48499) height=3.5324998 width=4.2910004]DECEMBER 31,
[Base Font : IOFOEO+Imago-Book, Font Size : 3.876, Font Weight : 0.0] [(X=307.5,Y=240.48499) height=3.876 width=2.9970093]respectively. The net decrease in the revenue
[Base Font : IOHLGA+Trebuchet, Font Size : 3.5324998, Font Weight : 0.0] [(X=49.5,Y=233.98499) height=3.5324998 width=2.5690002](US$ in millions)
I want to extract the value of "X" and the text associated and convert it to a list. Please, see the expected output below:
Expected Output:
['X=250.44','DECEMBER 31,']
['X=307.5','respectively. The net decrease in the revenue']
['X=49.5','(US$ in millions)']
How can we approach this in Python?
MyApproach:
mylist = []
for line in data.split("\n"):
if line.strip():
x_coord = re.findall('^(X=.*)\,$', line)
text = re.findall('^(]\w +)', line)
mylist.append([x_coord, text])
My approach does not identify any value for x_coord and text.