Neo4j also provides a command-line import tool. The executable is located in $NEO4J_HOME/bin/import. It requires several CSV files:
- One or several CSV file(s) for nodes with the following format:
id:ID,:LABEL,code,name,population_estimate_2019:int
1,State,CA,California,40000000
2,State,OR,Oregon,4000000
3,State,AZ,Arizona,7000000
- It is mandatory to have a unique identifier for nodes. This identifier must be identified with the :ID keyword.
- All fields are parsed as a string, unless the type is specified in the header with the :type syntax.
- One or several CSV file(s) for relationships with the following format:
:START_ID,:END_ID,:TYPE,year:int
1,2,SHARE_BORDER_WITH,2019
1,3,SHARE_BORDER_WITH,2019
Once the data files are created and located in the import folder, you can run the following:
bin/neo4j-admin import --nodes=import/states.csv --relationships=import/rel.csv
If you have very large files, the import tool can be much more convenient...