Hi Michael,

Thanks a lot, it works fine.

//Chargement du fichier
LOAD CSV WITH HEADERS FROM 'file:c:/Users/Fred/Desktop/scripts-test.csv' AS 
row FIELDTERMINATOR ';'
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 (s1)-[:AFTER]->(s2)
)
*WITH scripts, s*
MATCH (script:Script {name: scripts[0]})
CREATE (s)-[:EXECUTE]->(script)

I just added a WITH instruction as i had the following error message :
WITH is required between FOREACH and MATCH (line 10, column 1 (offset: 372))
"MATCH (script:Script {name: scripts[0]})"

And it works perfectly :



Fred
Le samedi 25 avril 2015 03:09:18 UTC+2, Michael Hunger a écrit :
>
> 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 cdu8...@gmail.com <javascript:>:
>
> 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)
>
> (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+un...@googlegroups.com <javascript:>.
> For more options, visit 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