我有2个CSV文件,我想将其转换为Neo4j数据库。它们看起来像这样:
first file:
name,enzyme
Aminomonas paucivorans,M1.Apa12260I
Aminomonas paucivorans,M2.Apa12260I
Bacillus cellulosilyticus,M1.BceNI
Bacillus cellulosilyticus,M2.BceNI
second file
name,motif
Aminomonas paucivorans,GGAGNNNNNGGC
Aminomonas paucivorans,GGAGNNNNNGGC
Bacillus cellulosilyticus,CCCNNNNNCTC
正如您所看到的,共同因素是有机体的名称和。每个生物都会有几个酶,每个酶都有1个主题。酶之间的基序可以相同。我使用以下语句来创建我的数据库:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
MATCH (o:Organism { name: csvLine.name}),(e:Enzyme { name: csvLine.enzyme})
CREATE (o)-[:has_enzyme]->(e)
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop/n_m.csv" AS csvLine
MATCH (o:Organism { name: csvLine.name}),(m:Motif { name: csvLine.motif})
CREATE (o)-[:has_motif]->(m)
但是我一直收到错误Cannot merge node using null property value for name (Failure when processing URL 'file:C:/Users/Desktop/n_e.csv' on line 2. No rows seem to have been committed. Note that this information might not be accurate.)
。我搜索了这个问题,但没有找到解决方法。我确保我的CSV
是“vanilla”csv(没有空格,只有逗号分隔)。但我一直遇到这个问题。我正在使用Neo4j的2.1.3
版本。任何帮助都将受到高度赞赏。
答案 0 :(得分:3)
一般情况下,请尝试并检查输出:
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
RETURN csvLine
LIMIT 5
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
RETURN csvLine.name,csvLine.enzyme
LIMIT 5
答案 1 :(得分:0)
在我的情况下,原因是标题行中的空格。例如,CVS
文件:
Name, Surname, City
Jan, Kowalski, Gdansk
所以,Name
导入正常,但Surname
未被识别(为空),
就像逗号和Surname
之间的空格一样。删除后,它开始工作。