cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Load data from CSV NO SQL - column name may vary

Is it possible import data from CSV with out specify the column name .
I may get CSV file with different column name so I cant specify the column name at the time load csv command

1 ACCEPTED SOLUTION

The simplest way is to just create a node and load the columns as properties of a node:

LOAD CSV WITH HEADERS FROM "file:///" as row
CREATE (n:Node)
SET n+= row

That is basically it, other than that you would have to add some dynamic logic like:

LOAD CSV WITH HEADERS FROM "file:///" as row
UNWIND keys(row) as key
// do something depending on the column key

View solution in original post

7 REPLIES 7

MuddyBootsCode
Graph Steward

I don't think you're going to be able to do that unless you did something along the lines of loading the row of your CSV into a list and then unwinding while using a generic name like list item at the index of the place in the array. Which would make it very hard to standardize what you're doing. You'd probably be better off creating something in your programming language of choice and then using a Neo4j driver to interact with your instance vs. trying to something generic with the load CSV tool.

This is possible, but you are limited in how do you want to design your graph schema.

please let me know the possibilities. Also node level I need measure which need for further query

The simplest way is to just create a node and load the columns as properties of a node:

LOAD CSV WITH HEADERS FROM "file:///" as row
CREATE (n:Node)
SET n+= row

That is basically it, other than that you would have to add some dynamic logic like:

LOAD CSV WITH HEADERS FROM "file:///" as row
UNWIND keys(row) as key
// do something depending on the column key

Thanks . 1 st time it may work but not sure if it work for 2nd load ( run process 2nd time ; Merge )

Thanks . Its works some extended though need to tweet little bit as per requirement but Really help full .

Thanks for your quick reply and suggestion .
How Neo4j handle no sql scenario . Any idea ? I will try as you suggest by different programming ( python ) . I may plan python to pivot the data