cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Load data from csv with head containing parenthes

sof10
Node Link

I want to load data from the local file .csv.
I wrote the cypher as follows,

LOAD CSV WITH HEADERS FROM url AS line With line CREATE (accident:Accident {identify:line.ID,zipcode:line.Zipcode,humidity:TOFLOAT(line.Humidity)})

But the Humidity column in the .csv is Humidity(%), so how do I process the property humidity when I load data from the local file.

If I wrote like this,
LOAD CSV WITH HEADERS FROM url AS line With line CREATE (accident:Accident {identify:line.ID,zipcode:line.Zipcode,humidity:TOFLOAT(line.Humidity(%))})
It is not right.
How to troubleshoot this problem?

2 REPLIES 2

koji
Ninja
Ninja

Hi,

You should surround the field names with backticks like this.

`Humidity(%)`

This is the sample.csv file.

"ID","Zipcode","Humidity(%)"
1,123456,10.1
2,789012,50.9
3,456789,12.8

LoadCSV Cypher

LOAD CSV WITH HEADERS FROM 'file:///sample.csv' AS line
CREATE (:Sample {
  id:       line.ID,
  zipcode:  line.Zipcode,
  humidity: toFloat(line.`Humidity(%)`)
});

2X_d_d8037ae5dd3dae52fe37ccb775ea8d8c801b6347.jpeg

Thanks so much for your help! It works.