pycharm链接neo4j(导入文件)

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)

4.结果展示

相关推荐
oooost21 小时前
Jupyter Notebook 常用快捷键速查
ide·python·jupyter
郝学胜-神的一滴1 天前
AI 编程智能体 02:AI智能体到底是什么
开发语言·人工智能·python·程序人生·pycharm
yqj2341 天前
ESP32-S3中小智项目优化内容
ide·macos·xcode
阿斌.com2 天前
Visual Studio 2026安装全攻略
ide·visual studio
我要神龙摆尾2 天前
IDEA 阅读插件
java·ide·intellij-idea·idea-plugs·plugs
梦幻通灵2 天前
IDEA 实用快捷键【持续更新】
java·ide·intellij-idea
风华同学3 天前
vscode远程连接
ide·vscode·编辑器
Sayai3 天前
Neo4j 内嵌模式(Embedded)实战:Java 嵌入式 vs 服务端部署的写入性能对比与 GC 调优
java·开发语言·性能优化·neo4j·图数据库
kiss strong3 天前
idea显示前进后退按钮
java·ide·intellij-idea