密码-删除具有特定值的所有属性 [英] Cypher - Remove all properties with a particular value

查看:57
本文介绍了密码-删除具有特定值的所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用Cypher删除具有特定值的数据库中任何节点的每个属性的方法.

I'm searching for a way to remove every property, of any node in the DB, having a specific value using Cypher.

上下文
我从具有大量NULL值的关系表中获取了一个csv批量文件. LOAD CSV将它们作为值.删除它们(用csv文件中的空''替换它们)会导致相同的问题(没有值的属性).尝试了许多(许多)Cypher操作以丢弃NULL值,但没有任何效果.

Context
I got a csv bulk file from a relational table with plenty of NULL values. LOAD CSV brings them as values. Removing them (replacing them with empty '' within the csv file) resulted in the same issue (properties without values). Tried many (many) Cypher operations to discard NULL values but nothing worked.

谷歌搜索也无法在文档中找到任何内容.可以仅使用Cypher来完成此操作吗?在我看来,(尚未)支持.

Can't find anything in the docs neither by Googling. Can this be done using only Cypher? It seems to me not (yet) supported.

谢谢.

推荐答案

如何处理(当您知道属性名称时):

How about this (when you know the property-names):

MATCH (n:Label)
WHERE n.property = ''
REMOVE n.property;

MATCH (u:User) 
WHERE u.age = '' 
SET u.age = null;

如果您知道这些列在您的导入中,则可以执行以下操作

If you know which columns these are in your import you can do something like this

load csv with headers from "" as line
with line, case line.foo when '' then null else line.foo end as foo
create (:User {name:line.name, foo:foo})

它不会使用null创建属性.

It won't create the properties with null.

对于数字值,toInt()和toFloat()在诸如"之类的不可解析的值上返回null更容易.

For numeric values it's easier as toInt() and toFloat() return null on unparseable values like ''.

这篇关于密码-删除具有特定值的所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆