Hello,
Objects in OpenStreetMap can have a variable number of key+value items, depending on what users recorded. As a result, after running a query through OverpassTurbo and exporting data in a GPX file, I end up with heterogenous data in the <desc>…</desc> section.
Is there a smarter way than going through different regexes?
Thank you.
Objects in OpenStreetMap can have a variable number of key+value items, depending on what users recorded. As a result, after running a query through OverpassTurbo and exporting data in a GPX file, I end up with heterogenous data in the <desc>…</desc> section.
Is there a smarter way than going through different regexes?
Thank you.
OSM_phone = re.compile("phone=(.+)") OSM_www = re.compile("website=(.+)") OSM_email = re.compile("email=(.+)") gpx = gpxpy.gpx.GPX() gpx_file = open(INPUT, mode='rt', encoding='utf-8') gpx = gpxpy.parse(gpx_file) for waypoint in gpx.waypoints: data = {} data["latitude"] = waypoint.latitude data["longitude"] = waypoint.longitude data["name"] = waypoint.name m = OSM_phone.search(waypoint.description) if m: data["phone"] = m.group(1) m = OSM_www.search(waypoint.description) if m: data["www"] = m.group(1) m = OSM_email.search(waypoint.description) if m: data["email"] = m.group(1) print(data)