Created
August 9, 2018 17:37
-
-
Save fferegrino/014b5c2ac0942b95d8b32c8f2d64405a to your computer and use it in GitHub Desktop.
Load airport data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD CSV WITH HEADERS FROM 'file:///flights.csv' as line | |
MATCH | |
(a:Airline{ iata: line.AIRLINE }), | |
(departure:Airport{ iata: line.ORIGIN_AIRPORT }), | |
(destination:Airport{ iata: line.DESTINATION_AIRPORT }) | |
WITH a, departure, destination, line | |
LIMIT #limit# | |
CREATE | |
(f:Flight{ | |
tail_number: line.TAIL_NUMBER, | |
flight_number: line.FLIGHT_NUMBER, | |
cancelled: line.CANCELLED <> "0", | |
time: line.SCHEDULED_TIME, | |
date: date({ year: toInteger(line.YEAR), month: toInteger(line.MONTH), day: toInteger(line.DAY) }), | |
diverted: line.diverted = "1", | |
distance: toInteger(line.DISTANCE) | |
}) | |
CREATE | |
(f)-[:OPERATED_BY]->(a), | |
(f)-[de:DEPARTED_FROM{ departure: { | |
scheduled: line.SCHEDULED_DEPARTURE, | |
delay: line.DEPARTURE_DELAY, | |
time: line.DEPARTURE_TIME | |
}}]->(departure), | |
(f)-[ar:ARRIVED_TO{ arrival: { | |
scheduled: line.SCHEDULED_ARRIVAL, | |
delay: line.ARRIVAL_DELAY, | |
time: line.ARRIVAL_TIME | |
}}]->(destination); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD CSV WITH HEADERS FROM 'file:///flights.csv' as line | |
MATCH | |
(a:Airline{ iata: line.AIRLINE }), | |
(departure:Airport{ iata: line.ORIGIN_AIRPORT }), | |
(destination:Airport{ iata: line.DESTINATION_AIRPORT }) | |
WITH a, departure, destination, line | |
LIMIT #limit# | |
CREATE | |
(f:Flight{ | |
tail_number: line.TAIL_NUMBER, | |
flight_number: line.FLIGHT_NUMBER, | |
cancelled: line.CANCELLED <> "0", | |
time: line.SCHEDULED_TIME, | |
date: date({ year: toInteger(line.YEAR), month: toInteger(line.MONTH), day: toInteger(line.DAY) }), | |
diverted: line.diverted = "1", | |
distance: toInteger(line.DISTANCE) | |
}) | |
CREATE | |
(f)-[:OPERATED_BY]->(a), | |
(f)-[de:DEPARTED_FROM{ | |
scheduled: line.SCHEDULED_DEPARTURE, | |
delay: line.DEPARTURE_DELAY, | |
time: line.DEPARTURE_TIME | |
}]->(departure), | |
(f)-[ar:ARRIVED_TO{ | |
scheduled: line.SCHEDULED_ARRIVAL, | |
delay: line.ARRIVAL_DELAY, | |
time: line.ARRIVAL_TIME | |
}]->(destination); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD CSV WITH HEADERS FROM 'file:///airports.csv' as line | |
CREATE | |
(:Airport{ | |
iata: line.IATA_CODE, | |
name: line.AIRPORT, | |
address: { | |
country: line.COUNTRY, | |
state: line.STATE, | |
city: line.CITY, | |
location: { | |
latitude: toFloat(line.LATITUDE), | |
longitude: toFloat(line.LONGITUDE) | |
} | |
} | |
}); | |
CREATE INDEX ON :Airport(iata); | |
LOAD CSV WITH HEADERS FROM 'file:///airlines.csv' as line | |
CREATE | |
(:Airline{ | |
iata: line.IATA_CODE, | |
name: line.AIRLINE | |
}); | |
CREATE INDEX ON :Airline(iata); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD CSV WITH HEADERS FROM 'file:///airports.csv' as line | |
CREATE | |
(:Airport{ | |
iata: line.IATA_CODE, | |
name: line.AIRPORT, | |
country: line.COUNTRY, | |
state: line.STATE, | |
city: line.CITY, | |
latitude: toFloat(line.LATITUDE), | |
longitude: toFloat(line.LONGITUDE) | |
}); | |
CREATE INDEX ON :Airport(iata); | |
LOAD CSV WITH HEADERS FROM 'file:///airlines.csv' as line | |
CREATE | |
(:Airline{ | |
iata: line.IATA_CODE, | |
name: line.AIRLINE | |
}); | |
CREATE INDEX ON :Airline(iata); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment