How to create individual node for each record of columnand as well as create relationship b/w the one among other fields in the same row .
For example.
A csv file with contains 20 columns like below,
Inc_number,description,priority,type,support_name and so on with many records.
How should we create each record/field as a individual node with relationship like below,
INC3506875->HARDWARE->Low->Justin
Thank you for your reply.
Yes We can load csv with referenced link. My question is how to create individual node of each record of column in same csv file.
Below cypher query will create only Node from node.Name column and then remaining of NoteType,modelLevel and so on are all propertyType of Entity . But am expecting all the fields of row value should be an individual node.
LOAD CSV WITH HEADERS FROM 'file:///EntityNodes.csv' AS node
CREATE (:Entity {name: node.Name, nodeType : node.NodeType, modelLevel : node.ModelLevel, modelRegion : node.ModelRegion, creator : node.Creator, dateTime : node.DateTime, isRole : node.isRole})
Thank you so much. Am getting the expected result using this query.Yes,I've to find out is their any options to iterate the whole dataset and define the model in a single attempt.
Wow, for the first time since I'm using Cypher, I found a limitation.
Sorry @mr.gsk0509, my query was wrong after testing it this after noon, it's not possible to use a variable as a label, and I guess, property name with the pure Cypher language.
I still need to confirm this in the manual, but still, this limitation is kind of sad.
For security purpose i guess.
though not directed specifically to the question posted initial on this thread but more so to your last post...
A variable can not be used as for a label not s much for security but rather because it would become impossible to determine a query plan.
For example if I had
match (n:$var1)-[:FOLLOWS]-(n2:Person) where n.age=20 return n;
then if $var1 was to represent :Person nodes then the planner could then check to see if :Person contained an index in property age but also could determine cardinality on n and n2 and determine what is the most efficient. But what if $var was not a static value for example
unwind ':Person, :Athlete, :Politician' as var
match (n:$var1)-[:FOLLOWS]-(n2:Person) where n.age=20 return n;
then here again planning would be a challenge.
However you could do this using apoc. For example if I had a .csv defined as
label,id,name
P1,1,Dana
P2,2,Tard
and then
load csv with headers from 'file:///dana.csv' as row call apoc.create.node([row.label],{name: row.name}) yield node return count(node);
would return
2
and
neo4j@dana> match (n:P1) return n;
+----------------------+
| n |
+----------------------+
| (:P1 {name: "Dana"}) |
+----------------------+
1 row available after 6 ms, consumed after another 2 ms
neo4j@dana> match (n:P2) return n;
+-----------------------+
| n |
+-----------------------+
| (:P2 {name: "Tard"}) |
+-----------------------+
It seems to me if you used a language like Python, you could construct the query with the value calculated so that you could construct the query string in Python before passing it onto Cypher.
Hi dana.canzano ,
Its working for single arugment like above sample which u provided. But am getting error if i added more than one argument itself. Pls see below error msg.
Procedure call provides too many arguments: got 3 expected no more than 2.
Procedure apoc.create.node has signature: apoc.create.node(label :: LIST? OF STRING?, props :: MAP?) :: node :: NODE?
meaning that it expects at least 2 arguments of types LIST? OF STRING?, MAP?
Description: apoc.create.node(['Label'], {key:value,...}) - create node with dynamic labels (line 1, column 55 (offset: 54))
"load csv with headers from 'file:///test1.csv' as row call apoc.create.node([row.label],{name: row.name},{project: row.project}) yield node return count(node);"
Is there any other option to add more number of individual field node items for each columns in csv spreadsheet.