====== Exemple de cargaments amb CSV ====== * lo fichièr es un nommat loadCantalausa.cql * l'escript es passat a l'interpretor del lengatge : cypher-shell ../bin/cypher-shell -u user -p passwd --debug < loadCantalausa.cql ==== loadCantalausa.cql ==== MATCH (p:Phrase) DETACH DELETE p; MATCH (c:Category) DELETE c; MATCH (r:Response) DELETE r; // Tables deleted CREATE CONSTRAINT ON (p:Phrase) ASSERT p.id IS UNIQUE; CREATE CONSTRAINT ON (r:Response) ASSERT r.id IS UNIQUE; CREATE CONSTRAINT ON (c:Category) ASSERT c.name IS UNIQUE; // Indices created //Phrase USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///cantalausa_phrase.csv' AS row WITH row CREATE (p:Phrase{id:TOINT(row.pid), name:row.phrase}); //Category USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///cantalausa_tag.csv' AS row WITH row CREATE (c:Category{id:TOINT(row.tid), name:row.label}); //Response USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///cantalausa_responsa.csv' AS row WITH row CREATE (r:Response{id:TOINT(row.rid), name:row.responsa}); // creation of the relations // creation of a fake node for the relation USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///cantalausa_phrase_tags.csv' AS row WITH row CREATE (r:hasCategory{from:TOINT(row.pid), to:TOINT(row.tid)}); // relationship creation MATCH (h:hasCategory) MATCH (c:Category{id:h.to}) MATCH (p:Phrase{id:h.from}) CREATE (p)-[:HAS_CATEGORY]->(c); // destroying fake relation node MATCH (h:hasCategory) DELETE h;