1 Star 0 Fork 0

xmasker/Knowledge Graph

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
chatgpt_analysis.py 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
xmasker 提交于 2023-08-30 21:49 . 修改
from py2neo import Graph, NodeMatcher, RelationshipMatcher
# 连接到Neo4j数据库
graph = Graph("http://localhost:7474", auth=("neo4j", "123456"))
# 导出节点和关系的内容
def export_data():
# 打开文件
with open("1.txt", "w") as file:
node_matcher = NodeMatcher(graph)
relationship_matcher = RelationshipMatcher(graph)
# 导出节点
nodes = node_matcher.match()
for node in nodes:
file.write("%s" % str(node))
# 导出关系
relationships = relationship_matcher.match()
for relationship in relationships:
# print(str(relationship))
file.write(str(relationship))
# 导出数据
export_data()
# from py2neo import Graph
# # 连接到Neo4j数据库
# graph = Graph("http://localhost:7474", auth=("neo4j", "123456"))
# # 导出节点和关系的内容,并将关系写入文件
# def export_data():
# # 打开文件
# with open("1.txt", "w") as file:
# relationship_list = []
# # 导出节点
# nodes = graph.nodes
# for node in nodes:
# file.write("%s" % node)
# # 导出关系
# relationships = graph.relationships
# for relationship in relationships:
# relationship_list.append(str(relationship))
# # 写入关系到文件
# file.write("\n".join(relationship_list))
# # 导出数据
# export_data()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xmasker/knowledge-graph.git
git@gitee.com:xmasker/knowledge-graph.git
xmasker
knowledge-graph
Knowledge Graph
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385