我有一个 CSV 文件,其中包含如下所示的公交车路线信息。我在 Neo4j 中以这种格式创建节点和路径关系时遇到问题。
我想要有停靠点和路线的节点,以及它们之间的路线,使用序列和路线详细信息 ID 来显示路线的方向。
RouteNameroute_detail_id |
顺序 |
停靠 |
站 |
到达 |
出发 |
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 是该特定路线上特定站点的唯一标识符。
我希望将来能够使用时间进行最短路径查询,但现在只想能够在 neo4j 中创建结构并可视化。
最终它将用于创建连接路线和最短路径搜索,但现在我什至无法将这种格式的信息转换为 Neo4j。
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.
发布评论
评论(1)
我首先将格式转换为由弧连接的节点列表,例如:
Cherry
--Bus1
、50701
、不适用
,9:00
-->市场
市场
--Bus1
、50802
、9:30
、10:00 --> -->
罗利
Cherry
--Bus2
、67003
、n/a
、11:00
-->Market
在我看来,这是一种更自然的表示数据的方式,因为您有站点(节点),它们通过巴士路线(有向弧线,带有路线详细信息)连接。
然后,您可以通过查找节点之间的链接来查询数据库。如果您想找到最短路径,您还可以将到达/出发时间转换为两个节点之间的旅程持续时间。
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.