1.新建csv文件
2.写入文件
3.运行代码
import csv
from py2neo import Graph, Node# 连接到Neo4j数据库,使用Bolt协议
graph = Graph("bolt://localhost:7687", auth=("neo4j", "password"))# 读取CSV文件
with open('D:\\Users\\ran\\PycharmProjects\\homework\\greedy_algorithm_data.csv', 'r', encoding='utf-8') as csvfile:reader = csv.DictReader(csvfile)for row in reader:# 创建节点node = Node(row['Type'], name=row['Name'], property=row['Property'], value=row['Value'])graph.create(node)# 查询并打印结果
results = graph.run("MATCH (n) RETURN n")
for record in results:print(record)