使用import csv文件方式创建知识图谱

1.查看是否有import文件夹

使用import csv文件方式创建知识图谱_第1张图片

2.在import文件夹里放入csv文件

使用import csv文件方式创建知识图谱_第2张图片

3.实用Cpyher语句,导入数据

LOAD CSV WITH HEADERS FROM "file:///julian_person.csv" AS line MERGE (p:Person {id:line.p_id, name:line.name, introduction:line.introduction})

LOAD CSV WITH HEADERS FROM "file:///julian_company.csv" AS line MERGE (c:BC_Company {id:line.c_id, name:line.name, tag:line.tag, introduction:line.introduction})

LOAD CSV WITH HEADERS FROM "file:///julian_p_c_rel.csv" AS line

match (from:Person{id:line.p_id}),(to:Company{id:line.c_id})

merge (from)-[r:member{p_id:line.p_id,c_id:line.c_id}]->(to)

关于乱码问题:

使用import csv文件方式创建知识图谱_第3张图片
load csv 中文编码乱码,  必须确保csv文件的编码格式:UTF8 无BOM格式




再增加一些关系节点

使用import csv文件方式创建知识图谱_第4张图片

Cpyher语句,导入数据:

LOAD CSV WITH HEADERS FROM "file:///chain_block_kg.csv" AS line MERGE (p:BC_Konwledge {id:line.id, name:line.name})

LOAD CSV WITH HEADERS FROM "file:///kg_rel.csv" AS line

match (from:BC_Knowledge{id:line.c_id}),(to:BC_Knowledge{id:line.id})

merge (from)-[r:isInculdeOf]->(to)

LOAD CSV WITH HEADERS FROM "file:///julian_c_kg_rel.csv" AS line

match (from:BC_Company{id:line.c_id}),(to:BC_Knowledge{id:line.kg_id})

merge (from)-[r:companyTagIs]->(to)

LOAD CSV WITH HEADERS FROM "file:///tokenview_coin.csv" AS line MERGE (p:Coin {id:line.id, name:line.name, Alias:line.alia, introduction:line.summaryCn})


参考文章:【1】基于电影知识图谱的智能问答系统(二) -- Neo4j导入CSV文件  实用,有数据可下载

你可能感兴趣的:(使用import csv文件方式创建知识图谱)