Parse into libraries and nodes
This commit is contained in:
parent
91704bb741
commit
3312cb6f23
1 changed files with 28 additions and 1 deletions
|
@ -4,6 +4,33 @@ import json
|
||||||
node_names = set()
|
node_names = set()
|
||||||
edges = []
|
edges = []
|
||||||
|
|
||||||
|
libraries = {}
|
||||||
|
locations = {}
|
||||||
|
with open("data/locaties.csv") as fp:
|
||||||
|
reader = csv.DictReader(fp, delimiter=";")
|
||||||
|
for item in reader:
|
||||||
|
locatie = item['Locatie'].split(',')
|
||||||
|
try:
|
||||||
|
lat, lon = locatie
|
||||||
|
except ValueError as e:
|
||||||
|
lat, lon = None, None
|
||||||
|
library = {
|
||||||
|
'name': item['Library Name'],
|
||||||
|
'code': item['Library Code'],
|
||||||
|
'adres': item['Adres'],
|
||||||
|
'lat': lat,
|
||||||
|
'lon': lon,
|
||||||
|
}
|
||||||
|
location = {
|
||||||
|
'location': item['Location Name'],
|
||||||
|
'code': item['Location Code'],
|
||||||
|
'library': library
|
||||||
|
}
|
||||||
|
|
||||||
|
libraries[library['name']] = library
|
||||||
|
locations[location['code']] = location
|
||||||
|
|
||||||
|
|
||||||
with open("data/requests.csv") as fp:
|
with open("data/requests.csv") as fp:
|
||||||
reader = csv.DictReader(fp, delimiter=";")
|
reader = csv.DictReader(fp, delimiter=";")
|
||||||
for item in reader:
|
for item in reader:
|
||||||
|
@ -17,7 +44,7 @@ nodes = [{'name': n} for n in node_names]
|
||||||
print(f"{len(nodes)} nodes, {len(edges)} edges")
|
print(f"{len(nodes)} nodes, {len(edges)} edges")
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'nodes': nodes,
|
'nodes': list(libraries.values()), #nodes,
|
||||||
'edges': edges
|
'edges': edges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue