Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
742 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
docs/asciidoc/modules/ROOT/partials/usage/apoc.export.xls.all.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
The examples in this section are based on the following sample graph: | ||
|
||
include::partial$createExportGraph.adoc[] | ||
|
||
The Neo4j Browser visualization below shows the imported graph: | ||
|
||
image::play-movies.png[] | ||
|
||
The `apoc.export.xls.all` procedure exports the whole database to an XLS file. | ||
|
||
The following query exports the whole database to the file `movies.xls`: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.export.xls.all("movies.xls", {}); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| file | source | format | nodes | relationships | properties | time | rows | batchSize | batches | done | data | ||
| "movies.xls" | "database: nodes(8), rels(7)" | "xls" | 8 | 7 | 21 | 102 | 15 | 20000 | 1 | TRUE | NULL | ||
|=== | ||
|
||
`movies.xls` contains individual sheets for each node label and relationship type. | ||
In this case, it contains the following sheets: | ||
|
||
* Movie | ||
* Person | ||
* ACTED_IN | ||
* DIRECTED | ||
* PRODUCED | ||
We can query the contents of those sheets using xref::overview/apoc.load/apoc.load.xls.adoc[]. | ||
Let's have a look at a couple of the sheets: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies.xls", "Movie"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | [0, 1999, "Welcome to the Real World", "The Matrix"] | {tagline: "Welcome to the Real World", `<nodeId>`: 0, title: "The Matrix", released: 1999} | ||
|=== | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies.xls", "ACTED_IN"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | [0, 1, 0, "Neo"] | {`<startNodeId>`: 1, `<endNodeId>`: 0, `<relationshipId>`: 0, roles: "Neo"} | ||
| 1 | [1, 2, 0, "Trinity"] | {`<startNodeId>`: 2, `<endNodeId>`: 0, `<relationshipId>`: 1, roles: "Trinity"} | ||
| 2 | [2, 3, 0, "Morpheus"] | {`<startNodeId>`: 3, `<endNodeId>`: 0, `<relationshipId>`: 2, roles: "Morpheus"} | ||
| 3 | [3, 4, 0, "Agent Smith"] | {`<startNodeId>`: 4, `<endNodeId>`: 0, `<relationshipId>`: 3, roles: "Agent Smith"} | ||
|
||
|=== |
48 changes: 48 additions & 0 deletions
48
docs/asciidoc/modules/ROOT/partials/usage/apoc.export.xls.data.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
The examples in this section are based on the following sample graph: | ||
|
||
include::partial$createExportGraph.adoc[] | ||
|
||
The Neo4j Browser visualization below shows the imported graph: | ||
|
||
image::play-movies.png[] | ||
|
||
The `apoc.export.xls.data` procedure exports the specified nodes and relationships to a XLS file. | ||
|
||
The following query exports all nodes with the `:Person` label with a `name` property that starts with `L` to the file `movies-l.csv`: | ||
|
||
[source,cypher] | ||
---- | ||
MATCH (person:Person) | ||
WHERE person.name STARTS WITH "L" | ||
WITH collect(person) AS people | ||
CALL apoc.export.xls.data(people, [], "movies-l.xls", {}) | ||
YIELD file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data | ||
RETURN file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data; | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| file | source | format | nodes | relationships | properties | time | rows | batchSize | batches | done | data | ||
| "movies-l.xls" | "data: nodes(3), rels(0)" | "xls" | 3 | 0 | 6 | 10 | 3 | 20000 | 1 | TRUE | NULL | ||
|=== | ||
|
||
`movies-l.xls` contains individual sheets for each node label and relationship type. | ||
In this case it contains a `Person` sheet. | ||
|
||
We can query the contents of those sheets using xref::overview/apoc.load/apoc.load.xls.adoc[]. | ||
Let's have a look at the `Person` sheet: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies-l.xls", "Person"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | [3, 1961, "Laurence Fishburne"] | {name: "Laurence Fishburne", `<nodeId>`: 3, born: 1961} | ||
| 1 | [5, 1967, "Lilly Wachowski"] | {name: "Lilly Wachowski", `<nodeId>`: 5, born: 1967} | ||
| 2 | [6, 1965, "Lana Wachowski"] | {name: "Lana Wachowski", `<nodeId>`: 6, born: 1965} | ||
|=== |
65 changes: 65 additions & 0 deletions
65
docs/asciidoc/modules/ROOT/partials/usage/apoc.export.xls.graph.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
The examples in this section are based on the following sample graph: | ||
|
||
include::partial$createExportGraph.adoc[] | ||
|
||
The Neo4j Browser visualization below shows the imported graph: | ||
|
||
image::play-movies.png[title="Movies Graph Visualization"] | ||
|
||
The `apoc.export.xls.graph` procedure exports a xref::virtual/index.adoc[virtual graph] to a CSV file or as a stream. | ||
|
||
The examples in this section are based on a virtual graph that contains all `PRODUCED` relationships and the nodes either side of that relationship. | ||
We can then export that virtual graph to `movies-producers.xls`: | ||
|
||
[source,cypher] | ||
---- | ||
MATCH path = (:Person)-[produced:PRODUCED]->(:Movie) | ||
WITH collect(path) AS paths | ||
CALL apoc.graph.fromPaths(paths, "producers", {}) | ||
YIELD graph AS g | ||
CALL apoc.export.xls.graph(g, "movies-producers.xls", {}) | ||
YIELD file, nodes, relationships, properties | ||
RETURN file, nodes, relationships, properties; | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| file | nodes | relationships | properties | ||
| "movies-producers.xls" | 2 | 1 | 5 | ||
|=== | ||
|
||
`movies-producers.xls` contains individual sheets for each node label and relationship type. | ||
In this case it contains the following sheets: | ||
|
||
* Movie | ||
* Person | ||
* PRODUCED | ||
We can query the contents of those sheets using xref::overview/apoc.load/apoc.load.xls.adoc[]. | ||
Let's have a look at a couple of the sheets: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies-producers.xls", "Person"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | [7, 1952, "Joel Silver"] | {name: "Joel Silver", `<nodeId>`: 7, born: 1952} | ||
|=== | ||
|
||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies-producers.xls", "PRODUCED"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | [6, 7, 0] | {`<startNodeId>`: 7, `<endNodeId>`: 0, `<relationshipId>`: 6} | ||
|=== |
46 changes: 46 additions & 0 deletions
46
docs/asciidoc/modules/ROOT/partials/usage/apoc.export.xls.query.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
The examples in this section are based on the following sample graph: | ||
|
||
include::partial$createExportGraph.adoc[] | ||
|
||
The Neo4j Browser visualization below shows the imported graph: | ||
|
||
image::play-movies.png[] | ||
|
||
The `apoc.export.xls.query` procedure exports the results of a Cypher query to a XLS file. | ||
|
||
The following query exports all `DIRECTED` relationships and the nodes with `Person` and `Movie` labels on either side of that relationship to the file `movies-directed.csv`: | ||
|
||
[source,cypher] | ||
---- | ||
WITH "MATCH path = (person:Person)-[:DIRECTED]->(movie) | ||
RETURN person.name AS name, person.born AS born, | ||
movie.title AS title, movie.tagline AS tagline, movie.released AS released" AS query | ||
CALL apoc.export.xls.query(query, "movies-directed.xls", {}) | ||
YIELD file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data | ||
RETURN file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data; | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| file | source | format | nodes | relationships | properties | time | rows | batchSize | batches | done | data | ||
| "movies-directed.xls" | "statement: cols(5)" | "xls" | 0 | 0 | 0 | 12 | 0 | 20000 | 1 | TRUE | NULL | ||
|=== | ||
|
||
`movies-directed.xls` contains one sheet with the name `Sheet0`. | ||
|
||
We can query the contents of this sheet using xref::overview/apoc.load/apoc.load.xls.adoc[]. | ||
Let's have a look at a couple of the sheets: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.load.xls("file://movies-directed.xls", "Sheet0"); | ||
---- | ||
|
||
.Results | ||
[opts="header"] | ||
|=== | ||
| lineNo | list | map | ||
| 0 | ["Lilly Wachowski", 1967, "The Matrix", "Welcome to the Real World", 1999] | {name: "Lilly Wachowski", tagline: "Welcome to the Real World", title: "The Matrix", released: 1999, born: 1967} | ||
| 1 | ["Lana Wachowski", 1965, "The Matrix", "Welcome to the Real World", 1999] | {name: "Lana Wachowski", tagline: "Welcome to the Real World", title: "The Matrix", released: 1999, born: 1965} | ||
|=== |
Oops, something went wrong.