Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.

Load CSV not recognizing columns

Node Clone

Hi everyone, I am trying to load a CSV file and the problem is that neo4j is not recognizing the headers and does not split the data in columns and basically considers each row as a list.

Another interesing aspect is that at the begining and ending of each row the data is between curly braces { }.

I am attaching a sample image of the dataset and an also the result in Neo4j

Thank you


Glad it worked! Appreciate your comments.

View solution in original post


Graph Maven

The data from .csv is incomplete and and apparently the data columns you presented is not being seen. Please post one full row of your .csv file so that I can help you. I did lot of .csv file imports from Neo4j versions from 3.0 to 4.1.1.

Hi ameyasoft, thank you for your reply... you are right some data columns are not displayed. I am uploading a TXT file (since I cannot upload CSV) with a single record.

Thanks again

subset1.txt (3.3 KB)

Best Regards

Thanks for the data file. As the column headers have blank spaces, you must include the column headers between back tics. Here is the Cypher that I used to import sample data. Also for null values please use COALESCE function.

LOAD CSV WITH HEADERS FROM "file:/subset1.csv" AS row
with row

MERGE (a:Col1 {col1: row.`?UID`})

MERGE (a1:Col2 {col2: row.`Anno Cargue SECOP`})

MERGE (a2:Col3 {col3: row.`Anno Firma del Contrato`})

MERGE (a3:Col4 {col4: row.`Nivel Entidad`})

RETURN a, a1, a2, a3

Created four nodes.

Here is the code with COALESCE function:

MERGE (a20:Col21 {col21: COALESCE(row.`Municipios Ejecucion`, 'NA')})

This created a node with col21 = 'NA'. This default value can be anything.

You can use COALESCE function for every column value. This inserts the default value only when the column value is null.

Hope this helps you.


Thank you, now I managed to load the several rows of the dataset

Best regards

Glad it worked! Appreciate your comments.

Node Clone

Hi, ameyasoft, thanks again for your help. I wonder if you can help me again since I am trying to load a similar CSV file whith the following data model

I am using the following code

LOAD CSV WITH HEADERS FROM "file:/10.csv" AS row
with row
  MERGE (a:CONTRATANTE {`NIT de la Entidad`: row.`NIT de la Entidad`, `Nivel Entidad`: row.`Nivel Entidad`})
  MERGE (b:CONTRATO {UID: row.`?UID`, `Cuantia Contrato_CUANT`: row.`Cuantia Contrato_CUANT`})
  MERGE (c:CONTRATISTA {`Identificacion del Contratista`: row.`Identificacion del Contratista`, `Nom Raz Social Contratista`: row.`Nom Raz Social Contratista`})
  MERGE (a) -[r:EMITE]-> (b)
  MERGE (b) -[s:ASIGNA]-> (c);

But I am getting an error related with a missing value while I do not have one

`Cannot merge node using null property value for Nivel Entidad (Failure when processing file....on line 2.)`

Thank you

10.txt (8.6 KB)

Thanks for sharing the file. My first suspicion was back tics in the header column. I copied your file into my import directory and tested. After the LOAD CSV statement I tried to return 4 rows (RETURN row limit 4) it shows the data with column names enclosed in back tics. Then I tried

RETURN row.`?UID` or row.`Nivel Entidad` 

both returning null values. The problem is with back tic in the column hearders. I deleted the back tics from the header row and used the updated file Ran the above query and both produced correct data.

Solution: Just remove the back tics in the header column and use your Cypher query and it should run . You need to keep the back tics in your Cypher query and not in the header column. Try and let me know.

Hi ameyasoft, it worked thank you very much


All is well that ends well!!