This should work

it aggregates the scripts into a collection
and then uses and index range to access the individual scripts

LOAD CSV WITH HEADERS FROM ... AS row
WITH row.Serveur as server, collect(row.Script) as scripts
MERGE (s:Server {id:server})
WITH s,scripts,size(scripts) as size
FOREACH (idx in range(0,size-2) |
  MERGE (s1:Script {name:scripts[idx]})
  MERGE (s2:Script {name:scripts[idx+1]})
  CREATE (s2)-[:AFTER]->(s1)
)
MATCH (script:Script {name: scripts[0]})
CREATE (s)-[:EXECUTE]->(script)


> Am 24.04.2015 um 23:38 schrieb cdu80...@gmail.com:
> 
> Hi all,
> 
> I've got .csv file with servers and scripts.
> 
> Serveur       Script
> AALTO Script1
> AALTO Script2
> AALTO Script3
> AALTO Script4
> ABBOTT        Script5
> ABBOTT        Script6
> ABBOTT        Script7
> ABBOUD        Script8
> ABBOUD        Script9
> ABBOUD        Script10
> ABBOUD        Script11
> ABBOUD        Script12
> 
> And i'd like to create following relationships :
> 
> (AALTO)-[:Execution]->(Script1)-[:Puis]->(Script2)-[:Puis]->(Script3)-[:Puis]->(Script4)
>  <applewebdata://36576DA0-8208-435D-A095-F9083E13F83F>
> (ABBOTT)-[:Execution]->(Script5)-[:Puis]->(Script6)-[:Puis]->(Script7)
> 
> (ABBOUD)-[:Execution]->(Script8)-[:Puis]->(Script9)-[:Puis]->(Script10)-[:Puis]->(Script11)-[:Puis]->(Script12)
> 
> Thanks a lot for your help.
> 
> Fred
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com 
> <mailto:neo4j+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to