首页>Program>source
MATCH (m:computer)
WITH collect(DISTINCT m) AS M
CALL apoc.export.csv.data( M, [], null, {stream:true, batchSize:100}) YIELD data as mdata

对于这样的查询,即使仅针对导出节点,也没有关系,它仍会为以下字段提供所有空值:

_start
  _end
  _type

在此过程中很难过滤掉它们.有参数可以控制吗?

添加项:

MATCH (m:SportsTeam)-[r:hasMember]-(n)
WITH collect(DISTINCT m) AS M, collect(DISTINCT n) AS N, collect(r) as R
CALL apoc.export.csv.data( M, [], null, {stream:true}) YIELD data
WITH apoc.text.replace(data, '(?:,"_start","_end","_type"|,,,)(?=\n)', '') AS mdata
CALL apoc.export.csv.data( N, [], null, {stream:true}) YIELD data as ndata
WITH apoc.text.replace(data, '(?:,"_start","_end","_type"|,,,)(?=\n)', '') AS ndata
CALL apoc.export.csv.data( [], R, null, {stream:true}) YIELD data as rdata
RETURN mdata, ndata, rdata

我在这里所做的是将节点M,节点N和关系R输出到3个不同的文件中.添加2个替换函数以删除最后3列后,它报告此错误:

neobolt.exceptions.CypherSyntaxError: Variable `N` not defined (line 5, column 28 (offset: 282))
"CALL apoc.export.csv.data( N, [], null, {stream:true}) YIELD data as ndata"

不能在这样的行中使用CALL和wITH吗?

最新回答
  • 1月前
    1 #

    您可以使用APOC函数apoc.text.replace修改CSV字符串以删除不需要的行:< / p>

    MATCH (c:computer)
    WITH COLLECT(DISTINCT c) AS cs
    CALL apoc.export.csv.data(cs, [], null, {stream:true, batchSize:100}) YIELD data
    WITH apoc.text.replace(data, '(?:,"_start","_end","_type"|,,,)(?=\n)', "") AS newData
    ... // use newData, which does not have the last 3 columns
    

    由于不需要的3列位于每行的末尾,因此正则表达式 (?:,"_start","_end","_type"|,,,)(?=\n) 与每行末尾(标题行或数据行)的不需要的文本匹配,然后将其删除。

  • python:具有多个连接的Rq worker
  • go:Logrus按需与syslog挂钩