Below is my code to create a neo4j relationship by reading from a csv file.
import csv
from py2neo import neo4j, cypher, authenticate, Graph
from py2neo import node, rel
import py2neo
authenticate("localhost:7474", "neo4j", "bhatt1234")
graph_db = neo4j.Graph("http://localhost:7474/db/data/")
ifile = open('agent_send.csv',"rb")
reader = csv.reader(ifile)
rownum = 0
for row in reader:
colnum = 0
for col in row:
rel = graph_db.merge({))
rownum += 1
ifile.close()
SO ,
I am looking to build a process to do daily imports from a csv to an already exisiting neo 4j. For that I need to use merge() statement. But I am grappling with using merge in py2neo. I need to use the merge between my csv and already existing nodes and relations in my neo4j db.
:START_ID(Agent),:END_ID(Agent),TXN_KEY,Amount,SendTime,PayTime,:TYPE
AEX053163,AEX010922,5000000000107593411,20.0,1361439,1362963.0,Agent_Send
AKJ063072,AS1034942,5000000000108495674,220.0,1361434,1362369.0,Agent_Send
ADT326742,AMX002998,5000000000106488543,1000.0,1361435,1363053.0,Agent_Send
ARA031639,AED100363,5000000000106029876,1669.0,1361424,1362506.0,Agent_Send
AKC403616,ADJ122111,5000000000107872144,180.0,1361415,1362680.0,Agent_Send
Above is a CSV which has a relation. So, how do I put this relation under g.merge()?
So , I was able to achieve the results by using LOAD CSV. It is a very handy utility to do everyday ETLs to the exisitng database.