I have some data that i get as a string from a file that is formatted as shown below. What i would like to do is create a vector (stored as a list in python) that indicates the difference in x,y,z directions between [x2, y2, z2] and [x1, x2, x3] for each line of the string shown below.
I should be fine in calculating the difference vector, once i have the desired [x2, y2, z2] and [x1, x2, x3] extracted as lists of integers. The thing i need help with is creating these [x2, y2, z2] and [x1, x2, x3] lists from the data below.
data = """x1=45 y1=74 z1=55 col1=[255, 255, 255] x2=46 y2=74 z2=55 col2=[255, 255, 255]
x1=34 y1=12 z1=15 col1=[255, 255, 255] x2=35 y2=12 z2=15 col2=[255, 255, 255]
x1=22 y1=33 z1=24 col1=[255, 255, 255] x2=23 y2=33 z2=24 col2=[255, 255, 255]
x1=16 y1=45 z1=58 col1=[255, 255, 255] x2=17 y2=45 z2=58 col2=[255, 255, 255]
x1=27 y1=66 z1=21 col1=[255, 255, 255] x2=28 y2=66 z2=21 col2=[255, 255, 255]
"""
Just to clarify, I only need to figure out how to extract the [x2, y2, z2] and [x1, x2, x3] lists for a single line. I can figure out how to loop for each line and calculate the difference vector for each line on my own. its just extracting the relevant data from each line and reformatting it into a usable format that has stumped me.
I suspect that using regular expressions is a potential avenue for extracting this information. I have looked at the documentation at https://docs.python.org/2/library/re.html and feel completely baffled and confused by that document. I just want an easy to understand way to do it.