为什么neo4j没有在csv数据中添加一个带有\n字符的新行?

hgqdbh6s  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(133)

我有一些来自csv的数据,其中有\n字符,我希望neo4j在将该字符串分配给节点中的某个属性时添加一个新行。显然它不起作用。我可以看到\n字符,因为它被添加到字符串中。
如何让它工作?提前感谢。
以下是CSV中的一个此类字符串示例:

Combo 4 4 4 5 \n\nSpare Fiber Inventory. \nMultimode Individual fibers from 9927/9928 to FDB.\nNo available spares from either BTS to FDB - New conduits would be required\n\nFrom FDB to tower top. 9 of 9 Spares available on 2.5 riser cables.

我的载入命令:

USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS 
FROM 'file:///abc.csv' AS line
WITH line WHERE line.parent <> "" AND line.type = 'LSD' AND line.parent_type = 'XYZ'
zf2sa74q

zf2sa74q1#

这是我的一个技巧,用换行符替换出现的\n。字符\是一个转义符,所以它会在第4行用新行替换\n。不要删除第5行并与第4行合并。

LOAD CSV WITH HEADERS 
FROM 'file:///abc.csv' AS line
WITH line WHERE line.parent <> ""
WITH replace(line.parent,'\\n',"   
") as parent
MERGE (p:Parent {parent: parent})

结果:

{
  "identity": 16,
  "labels": [
    "Parent"
  ],
  "properties": {
"parent": "Combo 4 4 4 5    

Spare Fiber Inventory.    
Multimode Individual fibers from 9927/9928 to FDB.   
No available spares from either BTS to FDB - New conduits would be required   

From FDB to tower top. 9 of 9 Spares available on 2.5 riser cables."
  }
}

相关问题