This procedure imports CSV files that comply with the link:https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin-import/#import-tool-header-format/[Neo4j import tool's header format].
=== Nodes
The following file contains two people:
.persons.csv
[source,text]
----
id:ID,name:STRING
1,John
2,Jane
----
We'll place this file into the `import` directory of our Neo4j instance.
We can create two `Person` nodes with their `name` properties set, by running the following query:
=== Import GraphML file created by Export GraphML procedures
`movies.graphml` contains a subset of Neo4j's movies graph, and was generated by the xref::export/graphml.adoc#export-graphml-whole-database[Export GraphML procedure].
<node id="n188" labels=":Movie"><data key="labels">:Movie</data><data key="title">The Matrix</data><data key="tagline">Welcome to the Real World</data><data key="released">1999</data></node>
We can run the following query to see the imported graph:
[source,cypher]
----
MATCH p=()-->()
RETURN p
----
.Results
[opts="header"]
|===
| p
| ({name: "Laurence Fishburne", born: "1961", labels: ":Person"})-[:ACTED_IN {roles: "[\"Morpheus\"]", label: "ACTED_IN"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999",
labels: ":Movie"})
| ({name: "Carrie-Anne Moss", born: "1967", labels: ":Person"})-[:ACTED_IN {roles: "[\"Trinity\"]", label: "ACTED_IN"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", la
bels: ":Movie"}) | ({name: "Lana Wachowski", born: "1965", labels: ":Person"})-[:DIRECTED {label: "DIRECTED"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", labels: ":Movie"})
| ({name: "Joel Silver", born: "1952", labels: ":Person"})-[:PRODUCED {label: "PRODUCED"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", labels: ":Movie"})
| ({name: "Lilly Wachowski", born: "1967", labels: ":Person"})-[:DIRECTED {label: "DIRECTED"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", labels: ":Movie"})
| ({name: "Keanu Reeves", born: "1964", labels: ":Person"})-[:ACTED_IN {roles: "[\"Neo\"]", label: "ACTED_IN"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", labels: ":
Movie"})
| ({name: "Hugo Weaving", born: "1960", labels: ":Person"})-[:ACTED_IN {roles: "[\"Agent Smith\"]", label: "ACTED_IN"}]->({tagline: "Welcome to the Real World", title: "The Matrix", released: "1999", la
bels: ":Movie"})
|===
The labels defined in the GraphML file have been added to the `labels` property on each node, rather than being added as a node label.
We can set the config property `readLabels: true` to import native labels:
.The following imports a graph based on `movies.graphml` and stores node labels
And now let's re-run the query to see the imported graph:
[source,cypher]
----
MATCH p=()-->()
RETURN;
----
.Results
[opts="header"]
|===
| p
| (:Person {name: "Lilly Wachowski", born: "1967"})-[:DIRECTED]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Carrie-Anne Moss", born: "1967"})-[:ACTED_IN {roles: "[\"Trinity\"]"}]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Hugo Weaving", born: "1960"})-[:ACTED_IN {roles: "[\"Agent Smith\"]"}]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Laurence Fishburne", born: "1961"})-[:ACTED_IN {roles: "[\"Morpheus\"]"}]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Keanu Reeves", born: "1964"})-[:ACTED_IN {roles: "[\"Neo\"]"}]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Joel Silver", born: "1952"})-[:PRODUCED]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
| (:Person {name: "Lana Wachowski", born: "1965"})-[:DIRECTED]->(:Movie {tagline: "Welcome to the Real World", title: "The Matrix", released: "1999"})
The `apoc.import.json` procedure can be used to import JSON files created by the xref::overview/apoc.export/index.adoc[`apoc.export.json.*`] procedures.
`all.json` contains a subset of Neo4j's movies graph, and was generated by xref::overview/apoc.export/apoc.export.json.all.adoc[].
The procedure support the following config parameters:
.Config parameters
[opts=header]
|===
| name | type | default | description | https://neo4j.com/docs/operations-manual/current/tools/import/options/[import tool counterpart]
| delimiter | String | , |delimiter character between columns | `--delimiter=,`
| arrayDelimiter | String | ; | delimiter character in arrays | `--array-delimiter=;`
| ignoreDuplicateNodes | Boolean | false | for duplicate nodes, only load the first one and skip the rest (true) or fail the import (false) | `--ignore-duplicate-nodes=false`