您好我是一名真正的初学者,并使用CSV文件进行如下操作,但不断获取为NULL Food节点创建的节点。任何提示?
Animals,Food,Cost,Description
dogs,dogfood,cheap,fluffy
dogs,meat,expensive,dirty
cats,catfood,expensive,fluffy
cats,,expensive,white
cats,,expensive,dirty
rabbit,cabbage,cheap,fluffy
rabbit,lettuce,cheap,black
我使用查询: -
LOAD CSV WITH HEADERS FROM "file:Q:/ASSISTANT TO TECH MANAGER/Neo4j Data/test.csv"
AS line
WITH line
WHERE line.Food IS NOT NULL
MERGE(animals:Animals{name:line.Animals})
MERGE(food:Food{name:line.Food})
MERGE(cost:Cost{cost:line.Cost})
MERGE(description:Description{description:line.Description})
MERGE (animals)-[e:EAT]->(food)-[c:COSTS]->(cost)
MERGE (animals)-[l:LOOK]->(description)
RETURN e,c,l
答案 0 :(得分:3)
保罗,
空字段仍然是字段。它不是空的。如果您仍想创建其他节点,则查询应类似于:
LOAD CSV WITH HEADERS FROM "file:Q:/ASSISTANT TO TECH MANAGER/Neo4j Data/test.csv"
AS line
MERGE(animals:Animals{name:line.Animals})
MERGE(cost:Cost{cost:line.Cost})
MERGE(description:Description{description:line.Description})
MERGE (animals)-[l:LOOK]->(description)
WITH line, animals, cost, l
WHERE line.Food <> ''
MERGE(food:Food{name:line.Food})
MERGE (animals)-[e:EAT]->(food)-[c:COSTS]->(cost)
RETURN e,c,l
恩典与和平,
吉姆