Reputation: 3845
Suppose I need to load a csv file c:\myData.csv
alfa,beta,gamma
0001,1000,thousant
0002,2000,two-K
...
in nodes
(:myData{alfa:0001,beta:1000,gamma'thousant'})
(:myData{alfa:0002,beta:2000,gamma'two-k'})
Is there a way to import ALL the columns into properties without specifying them one by one?
Something like
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line set line:myData create line
or
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line create (:myData {line.*})
Upvotes: 3
Views: 2358
Reputation: 51
Following worked for me after trying different options, Neo4j 3.3.2:
USING PERIODIC COMMIT 10000
LOAD CSV WITH HEADERS FROM 'file:///apples.csv' AS appleAllLineProperties
CREATE(apple:Apple)
set apple += appleAllLineProperties
Couple of observations:
Neo4j expects the file to be in the following folder
C:\Users\\AppData\Roaming\Neo4j Desktop\Application\neo4jDatabases\database-\installation-3.3.2\import
Upvotes: 5
Reputation: 41706
You can use
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line
create (:MyData {line})
or
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line
MATCH (m:MyData {id:line.id})
SET m += {line}
Upvotes: 2