PYTHON::知识图谱
仅当作记录
import py2neo from py2neo import Graph,Node,Relationship import pandas as pd graph = Graph("http://localhost:7474") graph = Graph("http://localhost:7474",uername="neo4j",password="lh990816") graph.delete_all()#清空所有内容 data = pd.read_excel("D:/data.xlsx") print(data.shape) datalable = list(data) data_row = len(data) print(data_row) # print(data.columns[1]) # b = Node(‘Person‘,name=‘yingying‘) # graph.create(b) datalable2 = len(datalable) print(datalable2) for i in range(0,data_row): print(data.loc[i][datalable[1]]) Nodee = Node(‘impentity‘,name = str(data.loc[i][datalable[1]])) graph.create(Nodee) for j in range(2,datalable2): print(data.loc[i][j]) print(data.columns[j]) # if(data.loc[i][j]==data.loc[i-1][j]): # selector = py2neo.matching.NodeMatcher(graph) # ndoe = selector.match(‘entity‘).where(‘_.name = "data.loc[i][j]"‘).first() # else: node = Node(‘entity‘,name = str(data.loc[i][j])) graph.create(node) graph.create(Relationship(Nodee,data.columns[j],node)) #print(data.head())
相关推荐
80530895 2020-07-05
boneix 2020-10-21
seanzed 2020-10-15
ifconfig 2020-10-14
学留痕 2020-09-20
往后余生 2020-09-17
kka 2020-09-14
redis 2020-09-07
lzccheng 2020-09-06
soyo 2020-08-31
stonerkuang 2020-08-18
LxyPython 2020-08-17
raksmart0 2020-08-17
Lzs 2020-08-14
MrHaoNan 2020-07-31
lengyu0 2020-06-28
YarnSup 2020-06-28
huanglianhuabj00 2020-06-27