Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-22-2021 10:47 PM
I am working on data for pension money withdrawal request. So data consists of 2 columns as shown below:
Operator ID, Activity Done
12, enter request
12, open
13, change
14, update
15, close
I wanted to create a graph like:
12----->12----->13----->14----->15----->15
I have tried many ways but was only able to create relationship between columns but not between rows.
Someone please help!
04-23-2021 01:08 AM
Hi. here is one approach to the query you are looking for
LOAD CSV WITH HEADERS from "{link to file}" as line
CREATE (n:Operator)
SET n.linenumber = linenumber(),
n.id = line.`Operator ID`,
n.activity = line.`Activity Done`
WITH n
MATCH (n1:Operator) WHERE n1.linenumber = n.linenumber-1
CREATE (n1)-[:HAS_RELATION]->(n)
REMOVE n.linenumber,n1.linenumber
RETURN n1,n
Using the line number.
04-23-2021 02:05 AM
Thank you @jaedag for the idea.
When applying it to my dataset it is showing: The execution plan for this query contains the Eager operator, which forces all dependent data to be materialized in main memory before proceeding. What does it mean? Do I need to worry about it?
04-23-2021 04:08 AM
in the LOAD CSV use a periodic commit
LOAD CSV - Neo4j Cypher Manual so as to reduce the memory footprint
04-23-2021 04:24 AM
Yes sorry. That's because you are creating nodes and then matching those same nodes in one query. You can split it into two queries like this to avoid the warning.
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS from "http://localhost:11001/project-619d0035-18f6-4531-bb33-5502f63c41a9/test.csv" as line
CREATE (n:Operator)
SET n.linenumber = linenumber(),
n.id = line.`Operator ID`,
n.activity = line.`Activity Done`;
MATCH (n:Operator)
MATCH (n1:Operator) WHERE n1.linenumber = n.linenumber-1
CREATE (n1)-[:HAS_RELATION]->(n)
REMOVE n.linenumber,n1.linenumber
RETURN n1,n;
This also uses the PERIODIC COMMIT
suggested by @dana.canzano
All the sessions of the conference are now available online