cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Should the property of a node be only integer or unique?

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!

1 ACCEPTED SOLUTION

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;

View solution in original post

4 REPLIES 4

12kunal34
Graph Fellow

HI @vishnuvardhans1698,

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

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

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;

This example seems to resonate with my current challenge. Could you please tell me what the store_id represents in your tabledata?

Thanks