我想在Neo4j中导入一个csv文件。以下是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
要在Neo4j中导入,我使用了:
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})
它导入除体育场信息以外的所有属性:名称和容量。 事实上这个:
LOAD CSV WITH HEADERS FROM
'file:///Z:/path/to/file/team.csv' as line
return line.stadium.name
返回:
我不明白为什么会发生这种事。体育场属性位于csv文件中。
答案 0 :(得分:2)
如果列标题里面有“奇怪”字符,比如点,则需要使用反引号引用标题:
LOAD CSV WITH HEADERS FROM 'file:///Z:/path/to/file/team.csv' as line
return line.`stadium.name`