CSV上传器 - 将多个列映射到单个属性

时间:2015-09-01 01:06:30

标签: csv neo4j

我有一个CSV(没有标题)..:

Electronics, Computer, Laptop, Small, Fast, New
Electronics, Computer, Desktop, Medium, Slow, Old
...

并且需要将多个CSV列上传为单个属性

LOAD CSV FROM "file://foo.csv" AS line
foreach (x in range(3,length(line)-2) | 
//some other stuff...
merge (s:T {word: line[x], describing: line[1], path: line[1..x]}

我将不得不稍后通过path属性查询每个节点:

Match (n:T) where n.path = "Computer, Desktop, Medium, Slow, Old"...

问题是,CSV上传程序会对所有引用的line[1..x]集合进行编码:

path property
["Computer", "Desktop", "Medium", "Slow", "Old"]

所以上面的查询会出现空白。有没有办法将多个CSV列上传到单个String属性中?

1 个答案:

答案 0 :(得分:3)

尝试将line[1..x]替换为:

REDUCE(s = "", y IN line[1..x] | s + (
  CASE WHEN LENGTH(s) = 0
    THEN ""
    ELSE ", "
  END) + y)

这应该生成一个以逗号分隔的字符串而不是字符串数组。