I have a splits
list of strings as follows:
splits = ['Heading_Error(deg):<br> base = 60.760321610086216<br> feature = 119.09070043133725<br> scene', '5G21A6P00L4100037:1566448100150275<br> object', "['f528bf65-9028-443d-8288-1efcd5c837cd', 'eb71c9c8-3924-4038-822f-0ac0508eb02c', 'e1f2c84b-fb37-4e33-8b5b-4f37d354d326']<br> cloud_uuid_feature = ['5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275']<br>"]
How can I extract the following fields?
scene = "5G21A6P00L4100037:1566448100150275"
objects = [
'f528bf65-9028-443d-8288-1efcd5c837cd',
'eb71c9c8-3924-4038-822f-0ac0508eb02c',
'e1f2c84b-fb37-4e33-8b5b-4f37d354d326'
]
cloud_uuid_feature = [
'5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275',
'5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275',
'5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275'
]
objects are a list of strings, cloud_uuid_feature is a list of string
Hoping the structure of your message holds good. I am joining the splits into a single string and find the necessary data.
import re
st=''.join(splits)
scene = re.findall('scene([^<]*)<br>',st)[0]
/// result '5G21A6P00L4100037:1566448100150275'
objects_str = re.findall('object\[([^\]]*)\]',st)[0]
objects=[x.strip().strip("'") for x in objects_str.split(',')]
/// result ['f528bf65-9028-443d-8288-1efcd5c837cd', 'eb71c9c8-3924-4038-822f-0ac0508eb02c', 'e1f2c84b-fb37-4e33-8b5b-4f37d354d326']
clouds_str = re.findall('cloud_uuid_feature.*\[([^\]]*)\]',st)[0]
cloud_uuid_feature = [x.strip().strip("'") for x in clouds_str.split(',')]
/// result ['5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.