neo4j-utils

Created: 2012-03-22 11:20
Updated: 2014-01-23 03:39
License: apache-2.0

README.md

Neo4j Utils

Neo4j utility classes

CsvImporter

Utility class to import nodes and relationships from tab (\t) separated files.

Nodes file format

First line of the file is a header:

key display_name prop_1 prop_2 prop_3 …

key and display_name are mandatory. They have to be the two first items. Next items are a 0..N list of node property names.

Other lines are node datas (on line per node):

MyKey01 Name to display First property Second property Third property

Rels file format

First line of the file is a header:

from_key to_key rel_type prop_1 prop_2 prop_3 …

from_key, to_key and rel_type are mandatory. They have to be the two first items. Next items are a 0..N list of node property names.

Other lines are relationship datas (on line per node):

MyKey01 MyKey02 TEST_TYPE First property Second property Third property

Usage

	File dbDirectory = new File("target/var");
	File testDatabasePath = new File(dbDirectory, "db-name.db");
	AbstractGraphDatabase graphDb = new EmbeddedGraphDatabase(testDatabasePath.getAbsolutePath());
	
	CsvImporter importer = new CsvImporter(graphDb, "myIndexName");
	importer.importNodes(MyClass.class.getResourceAsStream(/nodesFile.txt));
	importer.importRels(MyClass.class.getResourceAsStream(/relsFile.txt));
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more