cypher 如何忽略 CSV 格式的空格?

问题描述

我需要使用 SourceIP、DestinationIP、Timestamp 制作 CSV 文件信息的图表。但问题是每个 SourceIP、DestinationIP 和 Timestamp(仅限第一行)之前都有一个空格。我写了下面的查询,它在没有空间的地方工作正常。谁能帮我忽略空格?

LOAD CSV WITH HEADERS FROM 'file:/netflow1.csv' AS row 
WITH row WHERE row.sourceIP IS NOT NULL 
MERGE(source:m {Name:row.sourceIP})
MERGE(dest:n {Name:row.DestinationIP})
MERGE(source)-[r:To{Timestamp:row.Timestamp}]->(Dest)
WITH source,dest,row
MATCH(n) RETURN n

解决方法

有去除原字符串前后空格的字符串函数。

https://neo4j.com/docs/cypher-manual/current/functions/string/#functions-trim

修剪('str')

For example: RETURN trim('   hello   ')  will return "hello"