[Python-Neo4j] How do I generalize two or more .csv imported on neo4j and how do I calculate the critical path method for each graph?

6 views
Skip to first unread message

michele palumbo

unread,
Oct 1, 2017, 7:29:01 PM10/1/17
to Neo4j

I have several graphics created in .csv {Task1,Task2,Task3,ecc} and imported on neo4j using Python. This is an example:

GRAPH 1

"LOAD CSV WITH HEADERS FROM  'file:///A2_new.csv' AS line "\
  "CREATE (node:Task1 { ID: line.ID, attivita: line.attivita, descrizione: line.descrizione, predecessori: SPLIT(line.predecessori, ';'), durata: toInt(line.durata), inizio: line.inizio, fine: line.fine, nick: line.nick, ruolo: line.ruolo, start: toInt(REPLACE(line.inizio,'-', '')), finish: toInt(REPLACE(line.fine,'-', '')) } )" \
  "WITH node, SPLIT(line.predecessori, ';') AS predecessors " \
  "MATCH (p:Task1) " \
  "WHERE p.ID IN predecessors " \
  "MERGE (p)-[:RELAZIONE]->(node) "

GRAPH2

"LOAD CSV WITH HEADERS FROM  'file:///B2_new.csv' AS line "\
  "CREATE (node:Task2 { ID: line.ID, attivita: line.attivita, descrizione: line.descrizione, predecessori: SPLIT(line.predecessori, ';'), durata: toInt(line.durata), inizio: line.inizio, fine: line.fine, nick: line.nick, ruolo: line.ruolo, start: toInt(REPLACE(line.inizio,'-', '')), finish: toInt(REPLACE(line.fine,'-', '')) } )" \
  "WITH node, SPLIT(line.predecessori, ';') AS predecessors " \
  "MATCH (p:Task2) " \
  "WHERE p.ID IN predecessors " \
  "MERGE (p)-[:RELAZIONE]->(node) "

First question. How do I remove redundancy and use the same code block for each .csv (considering that all .csv have the same fields as you can see from the code above)?


Second question.At this point, I should calculate the critical path method for each graph. I would like to always calculate generically for each graph. How can I do and how do I get data from neo4j using Python?


Third question. Is there a library to display the jupiter graphics created?


Thank you so much

Reply all
Reply to author
Forward
0 new messages