harry-potter
harry-potter

Reputation: 2059

Import a csv file inNeo4j

I want to import in Neo4j a csv file. Here is an example of the file team.csv:

_id,official_name,common_name,country,started_by.day,started_by.month,started_by.year,championship,stadium.name,stadium.capacity,average age,squad value(in mln),foreigners
Cel.00,Real Club Celta de Vigo S.A.D.,Celta Vigo,Spain,30,11,1988,La Liga,Balaìdos,29500,25.7,60.4,10

To import in Neo4j I used:

LOAD CSV WITH HEADERS FROM 
'file:///Z:/path/to/file/team.csv' as line
create (p:Team {_id:line._id, official_name:line.official_name, common_name:line.common_name, country:line.country, started_by_day:"line.started_by.day",started_by_month:"line.started_by.month",started_by_year:"line.started_by.year", championship:line.championship,average_age:"line.average age", squad_value:"line.squad value(in mln)", foreigners:line.foreigners}), (p1:Stadium {name:line.stadium.name, capacity:line.stadium.capacity})

It imports all properties except stadium information:name and capacity. In fact this:

LOAD CSV WITH HEADERS FROM 
'file:///Z:/path/to/file/team.csv' as line
return line.stadium.name

returns:

enter image description here

I don't understand why this thing happens. Stadium properties are in the csv file.

Upvotes: 3

Views: 187

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39925

If a column header has 'strange' characters inside, like dots, you need to quote the header using backticks:

LOAD CSV WITH HEADERS FROM 'file:///Z:/path/to/file/team.csv' as line
return line.`stadium.name`

Upvotes: 2

Related Questions