batch-import
batch-import copied to clipboard
One row in csv -> one node created?
Do I understand this correct (I hope not): 1 row in csv file = 1 created node?
I have a JSON file of this kind: [ { "location" : { "country" : "CH", "refs" : [ { "target" : "D11595", "type" : "HLS" } ], "desc" : "Benediktinerkloster", "region" : "CH-SG", "settlement" : { "$ref" : "loc", "$id" : "loc000034" } }, "names" : [ { "lang" : "la", "text" : "Fabariense", "type" : "orig", "alias" : 1 }, { "lang" : "de", "text" : "Peffers", "type" : "orig" }, { "lang" : "de", "text" : "Pfaͤfers", "type" : "orig" }, { "lang" : "de", "text" : "Phêvers", "type" : "orig" } ], "_id" : "loc000001", "type" : "S.MSTY" }]
Then I convert it to CSV and get this:
location/country,location/refs/0/target,location/refs/0/type,location/desc,location/region,location/settlement/$ref,location/settlement/$id,names/0/lang,names/0/text,names/0/type,names/0/alias,names/1/lang,names/1/text,names/1/type,names/2/lang,names/2/text,names/2/type,names/3/lang,names/3/text,names/3/type,_id,type CH,D11595,HLS,Benediktinerkloster,CH-SG,loc,loc000034,la,Fabariense,orig,1,de,Peffers,orig,de,Pfaͤfers,orig,de,Phêvers,orig,loc000001,S.MSTY
which is actually 1 row. In my graph-DB I need some elements of this 1 line to be nodes, others - their properties. For example id would correspond to class place_id, which has an instance with a property loc_id = 'loc000001'. Fabariense is an instance of class placeName, which has property name = 'Fabariense'. Those two classes are related with a relationship, place_id has_name placeName
So, if the batch-importer will treat each row as one node with properties, this is not what I need. Please, correct me if I am wrong. I would be happy to hear any advice on how to get my JSON data into my Neo4j DB, which I am using via Neomodel. Sorry, if it is off topic.
I think what you're looking for is LOAD CSV in Cypher which allows you to take that single line and distribute it across any number of nodes and relationships. http://docs.neo4j.org/chunked/milestone/cypherdoc-importing-csv-files-with-cypher.html
With the batch-importer you'd either create multiple csv files (one per type of node) or have one file with a sparse matrix, i.e. one row per node but different columns with data.
Thank you very much for the piece of advice! Load CSV looks like what I need)) Now I have to upgrade my Neo4j to 2.1...