I have a CSV file with bus route information that looks like this. I am having trouble creating nodes and path relationships in Neo4j with it in this format.
I would like to have nodes for the stops and routes, and routes between them using the sequence and route detail id to show the direction of the routes.
RouteName | route_detail_id | Stop | Sequence | Arrives | Departs |
---|---|---|---|---|---|
Bus1 | 50701 | Cherry | 1 | 9:00 | |
Bus1 | 50802 | Market | 2 | 9:30 | 10:00 |
Bus1 | 59003 | Raleigh | 3 | 10:30 | 10:50 |
Bus1 | 59004 | Stuart | 4 | 11:05 | 11:30 |
Bus1 | 58006 | Possum | 5 | 12:30 | |
Bus2 | 67003 | Cherry | 1 | 11:00 | |
Bus2 | 67004 | Market | 2 | 11:30 | 12:00 |
Bus2 | 67009 | Raleigh | 3 | 12:30 | 12:50 |
Bus2 | 67010 | Stuart | 4 | 13:05 | 13:30 |
Bus2 | 67011 | Possum | 5 | 14:30 | |
Bus3 | 89004 | Highland | 1 | 9:00 | |
Bus3 | 88005 | McKinley | 2 | 9:30 | 10:00 |
Bus3 | 67098 | Jersey | 3 | 10:30 | 10:50 |
Bus3 | 4500 | Ridgewood | 4 | 11:05 | 11:30 |
Bus3 | 67890 | Osprey | 5 | 12:30 |
route_detail_id is the unique identifier for that particular stop on that particular route.
I would like to be able to use the times for shortest path queries in the future, but right now would just like to be able to create a structure and visualize in neo4j.
Eventually it will be used to create connecting routes, and shortest path searching, but right now I am just stumbling over even converting information in this format to Neo4j.
I would start by converting the format into a list of nodes connected by arcs, such as:
Cherry
--Bus1
,50701
,n/a
,9:00
-->Market
Market
--Bus1
,50802
,9:30
,10:00
-->Raleigh
Cherry
--Bus2
,67003
,n/a
,11:00
-->Market
This seems to me to be a more natural way of representing the data, as you have stops (nodes), which are connected by bus routes (directed arcs, with route details).
You can then query the database by looking for links between the nodes. You can convert also convert the arrival/departure times into the duration of the journey between two nodes if you want to find a shortest path.