Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use CSV to populate Neo4j

Tags:

neo4j

I am very new for Neo4j. I am a learner of this graph database. I need to load a csv file into Neo4j database. I am trying from 2 days,I couldn't able to find good information of reading the csv file in to Neo4j. Please suggest me wil sample code or blogs of reading csv file into Neo4j.

Example: Suppose if i have a csv file in This way how can we read it into Neo4j

id  name    language
1   Victor Richards West Frisian
2   Virginia Shaw   Korean
3   Lois Simpson    Belarusian
4   Randy Bishop    Hiri Motu
5   Lori Mendoza    Tok Pisin
like image 897
Navyah Avatar asked Dec 27 '22 15:12

Navyah


2 Answers

You may want to try https://github.com/sroycode/neo4j-import

This populates data directly from a pair of CSV files ( entries must be COMMA separated )

To build: (you need maven)

sh build.sh

The nodes file has a mandatory field id and any other fields you like

NODES.txt
id,name,language
1,Victor Richards,West Frisian
2,Virginia Shaw,Korean
3,Lois Simpson,Belarusian

The relationships file has 3 mandatory fields from,to,type. Assuming you have a field age ( long integer), and info, the relations file will look like

RELNS.txt
from,to,type,age@long,info
1,2,KNOWS,10,known each other from school
1,3,CLUBMATES,5,member of country club

Running:

sh run.sh graph.db NODES.txt RELNS.txt

will create graph.db in the current folder which you can copy to the neo4j data folder.

Note: If you are using neo4j later than 1.6.* , please add this line in conf/neo4j.properties

allow_store_upgrade = true

Have fun.

like image 181
SRC Avatar answered Feb 04 '23 18:02

SRC


Please take a look at https://github.com/jexp/batch-import

Can be used as starting point

like image 35
rmuller Avatar answered Feb 04 '23 16:02

rmuller