使用LOAD CSV创建Neo4j图数据库

时间:2022-04-25 18:03:12

I have a CSV file containing the data that I want to convert into a graph database using Neo4j. The Columns in the file are in the following format :

我有一个CSV文件,其中包含我想要使用Neo4j转换为图形数据库的数据。文件中的列采用以下格式:

Person1 | Person2 | Points

Person1 | Person2 |点

Now the ids in Person1 and Person2 are redundant , so I am using a Merge statement instead. But I am not getting the correct results. For a sample dataset , the output seems to be correct , but when I import my dataset consisting of 2M rows, it somehow doesn't create the relationships.

现在Person1和Person2中的ID是多余的,所以我使用的是Merge语句。但我没有得到正确的结果。对于样本数据集,输出似乎是正确的,但是当我导入包含2M行的数据集时,它不知何故不会创建关系。

I am putting the cypher code that I am using currently.

我正在使用我目前正在使用的密码。

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:C:/Users/yogi/Documents/Neo4j/default.graphdb/sample.csv" AS csvline
MERGE (p1:Person {id:toInt(csvline.id1)})
MERGE (p2:Person {id:toInt(csvline.id2)})
CREATE (p1)-[:points{count:toInt(csvline.c)}]->(p2)

1 个解决方案

#1


0  

Some things you should check:

你应该检查的一些事情:

  1. are you using an index: CREATE INDEX ON :Person(id) should be run before the import
  2. 你使用索引:CREATE INDEX ON:应该在导入之前运行Person(id)
  3. depending on the Neo4j version you're using, the statement might be subject to "eager-pipe" which basically prevents the periodic commit. For more on eager pipe, see http://www.markhneedham.com/blog/2014/10/23/neo4j-cypher-avoiding-the-eager/
  4. 根据您正在使用的Neo4j版本,该语句可能会受到“eager-pipe”的影响,这基本上会阻止定期提交。有关热切管道的更多信息,请访问http://www.markhneedham.com/blog/2014/10/23/neo4j-cypher-avoiding-the-eager/

#1


0  

Some things you should check:

你应该检查的一些事情:

  1. are you using an index: CREATE INDEX ON :Person(id) should be run before the import
  2. 你使用索引:CREATE INDEX ON:应该在导入之前运行Person(id)
  3. depending on the Neo4j version you're using, the statement might be subject to "eager-pipe" which basically prevents the periodic commit. For more on eager pipe, see http://www.markhneedham.com/blog/2014/10/23/neo4j-cypher-avoiding-the-eager/
  4. 根据您正在使用的Neo4j版本,该语句可能会受到“eager-pipe”的影响,这基本上会阻止定期提交。有关热切管道的更多信息,请访问http://www.markhneedham.com/blog/2014/10/23/neo4j-cypher-avoiding-the-eager/