I’m sure that many of you are very technical people – very knowledgeable about all things Java, Dr. Who and the like – but I in case you’ve ever met me, you would probably notice that I am not technical. And I don’t want to be.

I love technology, but have never had the talent, inclination nor education to program – so I don’t. But I still want to get data into Neo4j – so how do I do that?

There are many technical tools out there (definitely look here, here and here, but I needed something simpler.

So my friend and colleague Michael Hunger came to the rescue and offered me some help to create a spreadsheet to import data into Neo4j.

You will find the spreadsheet here, and you will find two components:
    1. An instruction sheet. I will get to that later.
    2. A data import sheet. Let’s look at that first.

The Data Import Sheet

This sheet is composed of two parts:
    • Columns A, B and C: These contain the data for the Nodes of our graph, using an “id”, a “name”, and a “type
    • Columns F, G and H: These contain the data for the Relationships of our graph, having a “from-id” (where the relationship starts), a “to-id” (where the relationship ends), and a “relationship type”. Columns F and G reference the nodes and their id’s in column A.

And then comes the secret sauce: How to create Cypher statements from these nodes and relationships.

For this we use very simple statements that leverage the columns mentioned above, the Cypher syntax and string concatenation. Look at the columns D and I:

    • Cypher statements to create the nodes:
create n={id:'"&A2&"', name:'"&B2&"', type:'"&C2&"'};

output for row 2:

create n={id:'1', name:'Amada Emory', type:'Female'};

As you can see, it takes that id, name and type properties from columns A, B and C, and puts these into a “create” Cypher statement.

    • Cypher statements to create the relationships:
start  n1=node:node_auto_index(id='"&F2&"'),
         n2=node:node_auto_index(id='"&G2&"')  create n1-[:"&H2&"]->n2;

output for row 2:

start  n1=node:node_auto_index(id='1'),
       n2=node:node_auto_index(id='11') create n1-[:MOTHER_OF]->n2;

This one is a little bit more complicated, as it will be using Neo4j’s auto-index: In order to create the relationship, we first have to look up a start node and an end node from the auto-index using the ID property. And then the create statement creates the relationship based on the relationship-type in column H.

So with this, we end up with two columns containing a bunch of Cypher statements. So then what?

The Instructions Sheet

In the first sheet of the spreadsheet, you will find a bunch of instructions. Basically, you need to go through the following steps:
    • Download Neo4j.
    • Copy/paste the Cypher statements from the Import Sheet into a text file.
    • Wrap these with a Neo4j transaction (begin, commit) – so that all of the statements get persisted to disk in the same transaction (or not in case of an error). (This is not important for smaller datasets, but is much more important for larger datasets.)
    • Some instructions on how to enable auto-indexing on Neo4j. This is important, because as you insert data into the database, it needs to get indexed for setting up the relationships properly (see above) and for future use.
    • And some instructions on how you can pipe the text file into the Neo4j shell – if necessary. For small datasets (and therefore, a limited number of Cypher statements) you can do with copy/pasting the text file into the Web-UI console – but that might not always work.
    • Starting the server and browsing the Web-UI


And there we go: The dataset gets created, and Neo4j is ready for use.

I hope this little overview was useful for you – it sure was useful for me when getting my hands dirty for the first time 🙂 …

Want to learn more about graph databases? Click below to get your free copy of O’Reilly’s Graph Databases ebook and discover how to use graph technologies for your application today.

Download My Free Copy



About the Author

Rik Van Bruggen , Regional VP & Neo4j Advocate

Rik Van Bruggen Image

Rik Van Bruggen brings 10 years experience in sales, specifically in web-based application development and security/identity management to his work at Neo Technology. Previously with Courion and Imprivata, Rik has managed sales and strived for customer success across Europe. Rik is a Belgian technology addict with a passion for sales, family, friends, music, travel, and of course, good food and even better, beer. Rik also runs the Graphistania podcast on graph databases.


Femi Adeyemi says:

This exactly what I've been looking for, because I have a spreadsheet file that contain more than 100,000 records and it wouldn't be pretty to start typing all into the neo4j. I will surely give it a try. Thank you!

Kristian says:

You could change the Cypher query for creating the relationships to use "create unique" instead of simply "create". This would ensure that no two identical relationships will be created, which might be of importance dealing with automatically generated spreadsheet data.

Aditya says:

Hi<br />I&#39;m using neo4j 1.8.2. <br />I&#39;m as new to it as one can be, and after going round and round for a while, decided to take this route towards importing the data. Nodes got created just fine. But while building the relationships I&#39;m running into the following:<br />MissingIndexException: Index `node_auto_index` does not exist<br />I looked up the discussions at http://

Anonymous says:

I cannot, for the life of me, get the web interface to return a single node. It says that all of them are there, but I cannot see them. Can you give a few demo queries to explore the data?

Aditya: were you able to resolve the autoindexing issue? Normally this is quite easily resolved by stopping the server, editing the config file, and restarting it. Note that only items that are added AFTER YOU ENABLE autoindexing will actually be indexed – so existing items are not indexed afterwards… You may need to re-add things? Let me know if that works or not.

&quot;Anonymous&quot;: if you just enter a node number in the search bar, eg. &quot;17&quot;, does it then return anything? <br /><br />if you run <br /><br />start n=node(*) return n;<br /><br />that should return a list of all nodes. Doesn&#39;t that work?

I&#39;m attempting to configure a demo on a Windows system. Is there an equivalent Windows CMD command line approach for running the import (or am I missing something in terms of locating a commmand line interface)? Thanks for any info.

karolina says:

Hi!<br />I was following the instructions and everything went ok.<br />The only thing I need is the command equivalent for windows…<br />You have :<br />cat import.txt | etc…<br />but this doesn&#39;t work in Win<br />:(

Julien says:


This topic is a little bit old but I have the same issue: for a Windows user, what is the command to enter instead of “cat import.txt | /bin/neo4j-shell -config conf/neo4j.properties -path /data/graph.db” ?

Sudip Paul says:

There is a perfect help for me. I have data in spreadsheet which needs to go in the database.However I see that the excel is not available at the URL anymore. Would you be kind to share it ? my email sudippaul@zoho.com

[…] used the spreadsheet method to import the metadata. It just did not make sense to go through the motions of prepping the CSV […]

goodguy says:

Did you do merge with your data? I have to process data when i use batchinser, especialy do merge!

Hans-Josef Wolf says:

Spreadsheet is no longer available at Google Docs. 🙁

guitou says:

What a pity! Please would it be possible to have available again please?

James says:

I am trying to follow this guide but I am running into issues. Could someone provide me with more detailed instructions?!

How do I ensure that “AUTO_INDEXING for neo4j is enabled”?!


1 Trackback

Leave a Reply

Your email address will not be published. Required fields are marked *