使用import csv檔案方式建立知識圖譜

weixin_34037977發表於2018-09-19

1.檢視是否有import資料夾

6102062-209d309a1d097260.png

2.在import資料夾裡放入csv檔案

6102062-95a3290e0e86aa58.png

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)

關於亂碼問題:

6102062-0ab0098d708b8e5d.png
load csv 中文編碼亂碼,  必須確保csv檔案的編碼格式:UTF8 無BOM格式




再增加一些關係節點

6102062-a58f6346f2b7616b.png

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檔案  實用,有資料可下載

相關文章