# Create individual node

**URL:** <https://community.neo4j.com/t/create-individual-node/32238>\
**Category:** Cypher\
**Created:** [January 18, 2021, 4:51am UTC](https://community.neo4j.com/t/create-individual-node/32238 "2021-01-18T04:51:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr.gsk0509](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mr.gsk0509/32/13095_2.png) [@mr.gsk0509](https://community.neo4j.com/u/mr.gsk0509)\
**Post date:** [January 18, 2021, 4:51am UTC](https://community.neo4j.com/t/create-individual-node/32238/1 "2021-01-18T04:51:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 18, 2021, 4:55am UTC](https://community.neo4j.com/t/create-individual-node/32238/2 "2021-01-18T04:55:22Z")

</div>

Please post couple of records with column headers for me to offer any solutions.  
Thanks.

---

<div class="post-metadata">

**Author:** ![mr.gsk0509](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mr.gsk0509/32/13095_2.png) [@mr.gsk0509](https://community.neo4j.com/u/mr.gsk0509)\
**Post date:** [January 18, 2021, 5:02am UTC](https://community.neo4j.com/t/create-individual-node/32238/3 "2021-01-18T05:02:48Z")

</div>

Hi ,  
Please find below records

| Incident\_Number | Summary | Service Type | Priority | Status | Submit Date | Last Resolved Date | Status Start Date | Status End Date | Group Assign Date | Group Re-Assign Date | Reopen | Pending | Pending Time | TTR with Pending | TTR excluding Pending | Support Organization | Assigned Group | VP (L3) | Manager |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| INC000006475856 | PHARMACY HARDWARE RELOCATION | User Service Request | Low | Assigned | 1/11/2019 13:14 | 3/2/2020 11:45 | 1/11/2019 13:14 | 2/17/2020 10:25 | 1/11/2019 13:14 | 2/21/2020 9:35 | 0 | 0 | 0 | 9982.5067 | 9982.5067 | Application | BOS Technology Worksite | NULL | Peter |
| INC000006311774 | PHARMACY HARDWARE RELOCATION/REMOVAL REQUEST - WORKSITE PHARMACY | User Service Request | Low | In Progress | 1/11/2019 13:14 | 3/2/2020 11:45 | 2/17/2020 10:25 | 2/21/2020 9:35 | 1/11/2019 13:14 | 2/21/2020 9:35 | 0 | 0 | 0 | 9982.5067 | 9982.5067 | Application | BOS Technology Worksite | NULL | Coyle |

---

<div class="post-metadata">

**Author:** ![tard\_gabriel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tard_gabriel/32/28033_2.png) [@tard\_gabriel](https://community.neo4j.com/u/tard_gabriel)\
**Post date:** [January 18, 2021, 6:04am UTC](https://community.neo4j.com/t/create-individual-node/32238/4 "2021-01-18T06:04:07Z")

</div>

> **[LOAD CSV - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/#load-csv-import-data-from-a-csv-file-containing-headers)**
>
> \`LOAD CSV\` is used to import data from CSV files.

---

<div class="post-metadata">

**Author:** ![mr.gsk0509](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mr.gsk0509/32/13095_2.png) [@mr.gsk0509](https://community.neo4j.com/u/mr.gsk0509)\
**Post date:** [January 18, 2021, 6:13am UTC](https://community.neo4j.com/t/create-individual-node/32238/5 "2021-01-18T06:13:27Z")

</div>

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})

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 18, 2021, 6:48am UTC](https://community.neo4j.com/t/create-individual-node/32238/6 "2021-01-18T06:48:37Z")

</div>

> [@mr.gsk0509](#):
>
> INC3506875-\>HARDWARE-\>Low-\>Justin

```auto
Try this:
LOAD CSV with headers from 'file:///test.csv' as row FIELDTERMINATOR '\t'
MERGE (i:Incident {number: row.Incident_Number})
CREATE (p:Priority {priority: row.Priority})
MERGE (m:AssinedTo {assignedTo: row.Manager})

CREATE (i)-[:HARDWARE]->(p)
CREATE (p)-[:ASSIGNED_TO]->(m)

```

Result:

 ![Screen Shot 2021-01-17 at 10.39.59 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/a/e/aeef6f591f22cf95aa11ca0c35ecfb89f01c75f0.png)

Your data has lot more information and you should think of a better data model.

---

<div class="post-metadata">

**Author:** ![tard\_gabriel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tard_gabriel/32/28033_2.png) [@tard\_gabriel](https://community.neo4j.com/u/tard_gabriel)\
**Post date:** [January 18, 2021, 6:53am UTC](https://community.neo4j.com/t/create-individual-node/32238/7 "2021-01-18T06:53:44Z")

</div>

Sorry, I'm a little bit tired and didn't correctly read your question.

I don't have my Neo4j desktop to test it, usually I test all my answer before bothering someone with a false answer. But can you test this:

LOAD CSV WITH HEADERS FROM 'file:///EntityNodes.csv' AS row  
FOREACH (columnName IN keys(row)| CREATE (:columnName {value:row.columnName})

---

<div class="post-metadata">

**Author:** ![mr.gsk0509](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mr.gsk0509/32/13095_2.png) [@mr.gsk0509](https://community.neo4j.com/u/mr.gsk0509)\
**Post date:** [January 18, 2021, 8:59am UTC](https://community.neo4j.com/t/create-individual-node/32238/8 "2021-01-18T08:59:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tard\_gabriel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tard_gabriel/32/28033_2.png) [@tard\_gabriel](https://community.neo4j.com/u/tard_gabriel)\
**Post date:** [January 18, 2021, 9:56pm UTC](https://community.neo4j.com/t/create-individual-node/32238/9 "2021-01-18T21:56:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [January 19, 2021, 12:34am UTC](https://community.neo4j.com/t/create-individual-node/32238/10 "2021-01-19T00:34:34Z")

</div>

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

```auto
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

```auto
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

```auto
label,id,name
P1,1,Dana
P2,2,Tard

```

and then

```auto
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

```auto
2

```

and

```auto
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"}) |
+-----------------------+

```

---

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [January 19, 2021, 2:04am UTC](https://community.neo4j.com/t/create-individual-node/32238/11 "2021-01-19T02:04:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tard\_gabriel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tard_gabriel/32/28033_2.png) [@tard\_gabriel](https://community.neo4j.com/u/tard_gabriel)\
**Post date:** [January 19, 2021, 4:42am UTC](https://community.neo4j.com/t/create-individual-node/32238/12 "2021-01-19T04:42:55Z")

</div>

I'm glad to know it, and as the planning is a huge part of Cypher there is no reason to expect that functionally soon or later.

Just to be sure, the planning is what turns the Cypher abstraction language to the graph database procedures.

---

<div class="post-metadata">

**Author:** ![mr.gsk0509](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mr.gsk0509/32/13095_2.png) [@mr.gsk0509](https://community.neo4j.com/u/mr.gsk0509)\
**Post date:** [January 21, 2021, 5:25am UTC](https://community.neo4j.com/t/create-individual-node/32238/13 "2021-01-21T05:25:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [January 21, 2021, 2:47pm UTC](https://community.neo4j.com/t/create-individual-node/32238/14 "2021-01-21T14:47:40Z")

</div>

[apoc.create.node - APOC Extended Documentation](https://neo4j.com/labs/apoc/4.1/overview/apoc.create/apoc.create.node/#usage-apoc.create.node) provides an example of the syntax to use when creating a node with multiple properties and in short detail effectively

```auto
:param labels => (["Human", "MovieStar"]);
:param properties => ({name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"});
CALL apoc.create.node($labels, $properties);

```

admittedly that not with a `load csv` statement but it should be transferrable to LOAD CSV and thus

```auto
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);

```
