mirror of
https://github.com/knejadshamsi/zele-utils.git
synced 2024-11-14 17:40:28 -05:00
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from bs4 import BeautifulSoup
|
|
import pandas,pyproj, re
|
|
from shapely.geometry import Point
|
|
|
|
def process_nodes(data):
|
|
ELEMENT_LIST = []
|
|
elements = BeautifulSoup(data,'lxml-xml')
|
|
for element in elements.find_all("node"):
|
|
ELEMENT_LIST.append(dict(element.attrs))
|
|
return pandas.DataFrame(ELEMENT_LIST)
|
|
|
|
def process_links(data):
|
|
ELEMENT_LIST = []
|
|
elements = BeautifulSoup(data,'lxml-xml')
|
|
for element in elements.find_all("link"):
|
|
ELEMENT_LIST.append(dict(element.attrs))
|
|
return pandas.DataFrame(ELEMENT_LIST)
|
|
|
|
def process_links_attr(data):
|
|
ELEMENT_LIST = []
|
|
elements = BeautifulSoup(data,'lxml-xml')
|
|
for element in elements.find_all("link"):
|
|
ELEMENT_DICT = {}
|
|
if element.find_all("attribute"):
|
|
for attr in element.find_all("attribute"):
|
|
ELEMENT_DICT.update({attr["name"]: attr.get_text()})
|
|
else:
|
|
continue
|
|
ELEMENT_DICT["id"]=element.getattr("id")
|
|
ELEMENT_LIST.append(ELEMENT_DICT)
|
|
|
|
return pandas.DataFrame(ELEMENT_LIST) |