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