Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-26-2020 03:16 AM
I have a table like this:
x y z prop
1 2 1 st
2 3 2 st
3 4 3 st
I'm writing pseudo code of what i did in python (Data is in form of dataframe in pandas):
(x:X{prop: $prop})
(y:Y{prop: $prop})
(x)-[r1:REL]->(y)
But there's an error as "TypeError: str object can't be intepretated as integer".
what is wrong in my code?
Thank You!
Peace!
Solved! Go to Solution.
02-29-2020 04:37 PM
LOAD CSV WITH HEADERS FROM 'file:///int.csv' AS line
CREATE (start:start_point{spoint: line.start_point})
CREATE (store:store_id{sid: line.store_id,items:line.Items})
CREATE (end:end_point{epoint: line.end_point})
CREATE (start)-[load_id1:LOAD{load_id:line.load_id}]->(store)
CREATE (store)-[load_id2:LOAD{load_id:line.load_id}]->(end)
MATCH (m:start_point)
WITH m.spoint as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
MATCH (m:store_id)
WITH m.sid as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
MATCH (m:end_point)
WITH m.epoint as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
02-26-2020 04:03 AM
could you please specify your requirement?
as I can understand you want to load data from df .
is that true ? if yes then could you please tell us what is the schema
02-28-2020 02:25 AM
sorry for the late reply. here's my exact dataframe:
load_id start_point end_point arrival time Items store_id
1 London Rockwell 12:39 biscuits s1
1 London Rockwell 1:40 biscuits s2
2 New hampshire London 12:40 biscuits s39
2 New hampshire London 12:40 cashew s39
2 New hampshire London 1:38 cashew s44
Now i want to store this data in my graph database.
My nodes are start_point and end_point and store_id.
And the property of each store is items. And the relationships are Node_ids.
It want something like this:
(start_point)--[load_id]--(store_id{items: })-->[load_id]-->(end_point)
Thanks!
Peace
02-29-2020 04:37 PM
LOAD CSV WITH HEADERS FROM 'file:///int.csv' AS line
CREATE (start:start_point{spoint: line.start_point})
CREATE (store:store_id{sid: line.store_id,items:line.Items})
CREATE (end:end_point{epoint: line.end_point})
CREATE (start)-[load_id1:LOAD{load_id:line.load_id}]->(store)
CREATE (store)-[load_id2:LOAD{load_id:line.load_id}]->(end)
MATCH (m:start_point)
WITH m.spoint as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
MATCH (m:store_id)
WITH m.sid as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
MATCH (m:end_point)
WITH m.epoint as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
05-15-2022 05:02 PM
This example seems to resonate with my current challenge. Could you please tell me what the store_id represents in your tabledata?
Thanks
All the sessions of the conference are now available online