How to auto-import csv content into Neo4j

You'll need to trigger a Cypher command, somehow. That could be an API method you add to Neo4j via a plugin. Though that's much trickier than you might think (I'm almost ready to publish an open plugin like this). Before you go too deep, check the import guide:

Your options:

  • Plugin to tweak the api, and handle the upload.
  • Driver on the server-side. Running Node.js as a middleman to provide the resource (server-side to handle the POST request) to receive and save the csv, then trigger the Cypher import command.
  • Use the Bolt driver in the client, to trigger the Cypher import command.
    • You'd have to build a way to make the CSV file accessible to Neo4j. That can be a url to the file (with some Neo configuration tweaks), or the file can be put in the $NEO_HOME/import directory.
    • Alternatively, you could parse the CSV in the client, and convert it into a set of native Cypher commands that would not require uploading the file.

Cypher IMPORT

The neo4j-javascript driver (docs) (github) can be used server-side, or client-side. There are two Cypher utilities that can import CSV:

However, both of these utilities require the file to already exist somewhere Neo can access.

Client Affect

If you're only building a javascript client, and you want the user to be able to create and upload the csv, then you're going to have to work some magic, and you have a few options:

  • Use a intermediary storage location, have the client send the CSV there, resulting in a URL that Neo4j can access, then run the Cypher import command through the neo4j-javascript driver.
  • Parse the csv in the client, and built the Cypher commands to MERGE/CREATE Nodes.