Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-08-2018 08:22 AM
I have used neo4j-import
when running Neo4j locally through command line. Lately I have been using Neo4j Desktop mostly lately to switch between multiple projects. I have a LOAD CSV
cypher file created and have used it to import one csv file that works really well. However, I have approximately 100 or so additional csv files that I would like to import into an existing database.
Is it possible to use neo4j-import
with an existing database, or possibly a way to use LOAD CSV
? Each file contains at least 10,000+ rows with ~200 columns each, so I will need to use PERIODIC COMMIT
.
This Stack Overflow Article seemed promising, but appears to indicate issues with using PERIODIC COMMIT
.
Solved! Go to Solution.
09-08-2018 05:06 PM
neo4j-import
cannot be used with existing databases
you can use apoc.perodic.iterate
call apoc.periodic.iterate("
unwind $files as file
load csv with headers from file as row return row",
"create (p:Person {name:row.name}) ...",
{batchSize:10000,iterateList:true});
09-08-2018 05:06 PM
neo4j-import
cannot be used with existing databases
you can use apoc.perodic.iterate
call apoc.periodic.iterate("
unwind $files as file
load csv with headers from file as row return row",
"create (p:Person {name:row.name}) ...",
{batchSize:10000,iterateList:true});
09-17-2018 07:53 PM
@michael.hunger Just wanted to update you and let you know that worked perfectly. I was able to import 2 files to make sure I had the progress down. Thanks again
09-23-2018 03:25 PM
I'd like to use apoc.periodic.iterate with flights_50k.csv which file from GraphConnect2017 import training.
call apoc.periodic.iterate("
unwind $files as file
load csv with headers from file as row return row",
"create (p:Person {name:row.name}) ...",
{batchSize:10000,iterateList:true});
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///flights_50k.csv" AS row
MERGE (origin:Airport {code: row.Origin})
MERGE (destination:Airport {code: row.Dest})
WITH row.UniqueCarrier + row.FlightNum + " " + row.Year + "-" + row.Month + "-" + row.DayofMonth + " " + row.Origin + "_" + row.Dest AS flightIdentifier, row, origin, destination
MERGE (flight:Flight { id: flightIdentifier })
ON CREATE SET flight.date = row.Year + "-" + row.Month + "-" + row.DayofMonth,
flight.airline = row.UniqueCarrier, flight.number = row.FlightNum, flight.departure = row.CRSDepTime,
flight.arrival = row.CRSArrTime, flight.distance = row.Distance, flight.cancelled = row.Cancelled
MERGE (flight)-[:ORIGIN]->(origin)
MERGE (flight)-[:DESTINATION]->(destination)
I tried to merge apoc.periodic,iterate and LOAD CSV~~.
However, I failed with below ERROR
WHAT're wrong with me?
09-23-2018 03:31 PM
I tried with below.
$files = "file:///flight_init.csv"
call apoc.periodic.iterate("
UNWIND $files as file
load csv with headers from file as row return row",
{batchSize:10000,iterateList:true});
But, I've got error.
09-23-2018 03:22 PM
@michael.hunger I'd like to use apoc.periodic.iterate with flights_50k.csv which file from GraphConnect2017 import training.
call apoc.periodic.iterate("
unwind $files as file
load csv with headers from file as row return row",
"create (p:Person {name:row.name}) ...",
{batchSize:10000,iterateList:true});
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///flights_50k.csv" AS row
MERGE (origin:Airport {code: row.Origin})
MERGE (destination:Airport {code: row.Dest})
WITH row.UniqueCarrier + row.FlightNum + "" + row.Year + "-" + row.Month + "-" + row.DayofMonth + "" + row.Origin + "_" + row.Dest AS flightIdentifier, row, origin, destination
MERGE (flight:Flight { id: flightIdentifier })
ON CREATE SET flight.date = row.Year + "-" + row.Month + "-" + row.DayofMonth,
flight.airline = row.UniqueCarrier, flight.number = row.FlightNum, flight.departure = row.CRSDepTime,
flight.arrival = row.CRSArrTime, flight.distance = row.Distance, flight.cancelled = row.Cancelled
MERGE (flight)-[:ORIGIN]->(origin)
MERGE (flight)-[:DESTINATION]->(destination)
I tried to merge apoc.periodic,iterate and LOAD CSV~~.
However, I failed with below ERROR
FROM
call apoc.periodic.iterate("
load csv with headers from "file:///flight_init.csv" as row return row",
"MERGE (origin:Airport {code: row.Origin})
MERGE (destination:Airport {code: row.Dest})
WITH row.UniqueCarrier + row.FlightNum + "" + row.Year + "-" + row.Month + "-" + row.DayofMonth + "" + row.Origin + "_" + row.Dest AS flightIdentifier, row, origin, destination
MERGE (flight:Flight { id: flightIdentifier })
ON CREATE SET flight.date = row.Year + "-" + row.Month + "-" + row.DayofMonth,
flight.airline = row.UniqueCarrier, flight.number = row.FlightNum, flight.departure = row.CRSDepTime,
flight.arrival = row.CRSArrTime, flight.distance = row.Distance, flight.cancelled = row.Cancelled
MERGE (flight)-[:ORIGIN]->(origin)
MERGE (flight)-[:DESTINATION]->(destination)",
{batchSize:10000,iterateList:true});
WHAT're wrong with me?
09-24-2018 11:39 AM
The quotes are wrong, you cannot use "
within "
without escaping them e.g. \"
or by using single quotes '
inside of the statement.
All the sessions of the conference are now available online