thank you sir for answering me
I added the line of code you sent me regarding the constraint instead of the two lines of antecedent.
I attach below the complete code that I used as well as the results obtained.
to inform you about the stop_times table which includes the primary key composed when creating the relationship that exists between this table and the two tables trips and stops (in which its main key is composed of the two primary keys of these two tables: trips and stops, I got the following error message:
"Neo.DatabaseError.Statement.ExecutionFailed: java.net.URISyntaxException: Illegal character in path at index 6: file:/stop_times.csv"
How do you think this should be resolved?
waiting for a favorable response, please accept sir my best regards.
// Create unique constraints agency routes trips stop_times calendar stops
CREATE CONSTRAINT constraint_agency IF NOT EXISTS FOR (agency:Agency) REQUIRE agency.agency_id IS UNIQUE;
CREATE CONSTRAINT constraint_route IF NOT EXISTS FOR (route:routes) REQUIRE route.route_id IS UNIQUE;
CREATE CONSTRAINT constraint_trips IF NOT EXISTS FOR (trip:trips) REQUIRE trip.trip_id IS UNIQUE;
//CREATE CONSTRAINT constraint_stop_times IF NOT EXISTS FOR (stop_time:stop_times) REQUIRE stop_time.trip_id IS UNIQUE;
//CREATE CONSTRAINT constraint_stop_times IF NOT EXISTS FOR (stop_time:stop_times) REQUIRE stop_time.stop_id IS UNIQUE;
CREATE CONSTRAINT stop_times_node_key IF NOT EXISTS FOR (n:stop_times) REQUIRE (n.stop_id, n.trip_id) IS NODE KEY
CREATE CONSTRAINT constraint_calendar IF NOT EXISTS FOR (calendar:calendar) REQUIRE calendar. service_id IS UNIQUE;
CREATE CONSTRAINT constraint_stops IF NOT EXISTS FOR (stop:stop) REQUIRE stop.stop_id IS UNIQUE;
//. Creation des noeuds pour chaque classes d’entités agency routes trips stop_times calendar stops.
// Create agency nodes
LOAD CSV WITH HEADERS FROM "file:///agency.csv" AS line
MERGE (agency:agency {agency_id: line.agency_id})
SET agency+= {
agency\_name: line. agency\_name,
agency\_url: line. agency\_url,
agency\_timezone: line. agency\_timezone,
agency\_phone: line. agency\_phone,
agency\_lang: line. agency\_lang,
agency\_fare\_url: line. agency\_fare\_url
};
// Create routes nodes
LOAD CSV WITH HEADERS FROM "file:///routes.csv" AS line
MERGE (route:routes {route_id: line. route_id })
SET route += {
agency\_id: line.agency\_id,
route\_short\_name: line. route\_short\_name,
route\_long\_name: line.route\_short\_name,
route\_type: line.route\_type
};
// Create trips nodes
LOAD CSV WITH HEADERS FROM "file:///trips.csv" AS line
MERGE (trip:trips {trip_id: line.trip_id})
SET trip+= {
route\_id: line. route\_id,
service\_id: line. service\_id,
trip\_headsign: line. trip\_headsign
};
// Create calendar nodes
LOAD CSV WITH HEADERS FROM "file:///calendar.csv" AS line
MERGE (calendar:calendar {service_id: line.service_id})
SET calendar+= {
monday: line.monday,
tuesday: line.tuesday,
wednesday: line.Wednesday,
thursday: line.Thursday,
friday : line.Friday,
saturday: line. Saturday,
sunday: line. Sunday,
start\_date: line. start\_date,
end\_date: line. end\_date
};
// Create stop_times nodes
LOAD CSV WITH HEADERS FROM "file:///stop_times.csv" AS line
MERGE (stop_times:stop_times {stop_id:line.stop_id, trip_id:line.trip_id})
SET stop_times+= {
arrival\_time: line. arrival\_time,
departure\_time: line. departure\_time,
stop\_sequence: line. stop\_sequence,
stop\_headsign: line.stop\_headsign
};
// Create stops nodes
LOAD CSV WITH HEADERS FROM "file:///stops.csv" AS line
MERGE (stops:stops {stop_id: line.stop_id})
SET stops+= {
stop\_desc: line. stop\_desc,
stop\_lat: line. stop\_lat,
stop\_lon: line. stop\_lon,
zone\_id: line. zone\_id,
loc\_type:line. loc\_type,
stop\_name :line. stop\_name
};
// create relationships between (agency p, routes f : agency_id) (routes p, trips f : route_id) (calendar p, trips f : service_id) (stops p, stop_times f : stop_id) (trips p, stop_times f : trip_id)
// create relationships between (agency p, routes f : agency_id)
LOAD CSV WITH HEADERS FROM "file:///routes.csv" AS line
MATCH (route:routes {route_id: line.route_id})
MATCH (agency:agency {agency_id: line.agency_id})
MERGE (route)-[:related]->(agency);
// create relationships between (routes p, trips f : route_id)
LOAD CSV WITH HEADERS FROM "file:///trips.csv" AS line
MATCH (trip:trips {trip_id: line.trip_id})
MATCH (route:routes {route_id: line.route_id})
MERGE (trip)-[:related1]->(route);
// create relationships between (calendar p, trips f : service_id)
LOAD CSV WITH HEADERS FROM "file:///trips.csv" AS line
MATCH (trip:trips {trip_id: line.trip_id})
MATCH (calendar:calendar {service_id: line.service_id})
MERGE (trip)-[:related2]->(calendar);
// create relationships between (stops p, stop_times f : stop_id)
LOAD CSV WITH HEADERS FROM "file:/// stop_times.csv" AS line
MATCH (n: stop_times {trip_id: line.trip_id, stop_id: line. stop_id})
MATCH (stop:stops {stop_id: line.stop_id})
MERGE (n)-[:related3]->(stop);
// create relationships between (trips p, stop_times f : trip_id)
LOAD CSV WITH HEADERS FROM "file:/// stop_times.csv" AS line
MATCH (n: stop_times {trip_id: line.trip_id, stop_id: line. stop_id})
MATCH (trip:trips {trip_id: line.trip_id})
MERGE (n)-[:related4]->(trips);