2

I'm using py2neo with Neo4j v3.

I load some CSV files, create indexes and do some matching:

graph.run("MATCH (n) DETACH DELETE n")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_officer.csv' AS row CREATE (n:Officer) SET n = row;")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_company.csv' AS row CREATE (n:Company) SET n = row;")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_company_officer.csv' AS row CREATE (n:CompanyOfficer) SET n = row;")
graph.run("CREATE INDEX ON :Officer(officer_id);")
graph.run("CREATE INDEX ON :Company(company_id);")
graph.run("MATCH (o:Officer), (co:CompanyOfficer) WHERE o.officer_id = co.officer_id CREATE (o)-[:linked]->(co);")
graph.run("MATCH (co:CompanyOfficer), (c:Company) WHERE co.company_id = c.company_id CREATE (co)-[:linked]->(c);")

Then, I open up Neo4j in my browser (http://localhost:7474/) and run the command:

START n=node(*) RETURN n

and then I export the graph.

My question: how do I automate this? So that the resulting graph is saved when my python script finishes running? (So completely remove the need to open up Neo4j in my browser.)

Sorry if this question has been asked elsewhere - I did a lot of Googling and had no luck...

Thanks in advance :) Sam

Sam Short
  • 183
  • 1
  • 1
  • 9
  • 1
    The views that you get in the browser are completely separate from the database. You can return data in JSON format with Python, but there's no connection between the pretty bubble picture and the Python database connection. – Tore Eschliman Oct 07 '16 at 13:08
  • And worth a note that the browser has a default 25 or so limit on the data is returns – Chris White Oct 07 '16 at 13:33
  • that limit is much higher in 3.0, but there is still a limit. – Tore Eschliman Oct 07 '16 at 14:47

0 Answers0