首页 文章

从Dropbox for Neo4j加载CSV文件

提问于
浏览
4

我将我的csv文件保存在Dropbox上,我想在Neo4j上加载它们 .

共享 Users Node csv文件的链接:https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0

这是密码

USING PERIODIC COMMIT 100

LOAD CSV WITH HEADERS FROM "https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0" AS line

CREATE(u:User{userId: toInt(line.Id), username: line.UserName, fullname: line.FullName})

我使用的Neo4j版本是Neo4j企业版3.0.9 .

结果显示它成功创建了用户节点,但它创建了超过300个节点,没有用户名和全名,即使在CSV文件上有9个用户名和全名的节点 . 我错过了什么?

我试图将共享链接中的URL更改为 download link ,但错误 Couldn't load the external resource 出现了 .

3 回答

  • 4

    如果您从Dropbox切换到gDrive,问题似乎不是问题 . 我把你的csv放在我的驱动器帐户中,它似乎工作 .

    USING PERIODIC COMMIT 100
    LOAD CSV WITH HEADERS FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vRANVgt-GZf0Un8dyrf7YPITDgAIBzTwjTcqOu_G7mBhGKOEZskf6Mt2oTdInyQ-wLPE0aOzsW6lVD_/pub?gid=5399540&single=true&output=csv" AS line
    CREATE(u:User{userId: toInt(line.Id), username: line.UserName, fullname: line.FullName})
    

    文件>发布到网络

    enter image description here

    • 选择所需的标签

    • 选择csv作为已发布的格式

    • 单击“发布”

    你会收到一个公共网址到csv

    enter image description here

  • 3

    您使用的链接本身不是文件,而是用于查看文件的保管箱页面:

    $ curl -i --raw https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0
    HTTP/2 302
    server: nginx
    date: Mon, 24 Jul 2017 14:46:44 GMT
    content-type: text/html; charset=utf-8
    content-length: 0
    location: https://dl.dropboxusercontent.com/content_link/Z2KG0dzjBlHuMnIXyApZvBZFICVBXnLErAeLwlrkH46xnjg5yfd59ZfboKUpCNdo/file
    

    您应该尝试使用文件直接链接:

    $ curl -i --raw https://dl.dropboxusercontent.com/content_link/Z2KG0dzjBlHuMnIXyApZvBZFICVBXnLErAeLwlrkH46xnjg5yfd59ZfboKUpCNdo/file
    HTTP/2 200
    server: nginx
    date: Mon, 24 Jul 2017 14:47:46 GMT
    content-type: text/csv; charset=utf-8
    content-length: 231
    
  • 3

    发生这种情况是因为链接https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0返回HTML页面而不是CSV文件 .

    看看这个Cypher查询:

    LOAD CSV WITH HEADERS FROM "https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0" AS line
    RETURN line LIMIT 3
    

    输出:

    ╒══════════════════════════════════════════════════════════════════════╕
    │"line"                                                                │
    ╞══════════════════════════════════════════════════════════════════════╡
    │{"<!DOCTYPE html><html lang=\"en\" xmlns:fb=\"http://ogp.me/ns/fb#\" x│
    │ml:lang=\"en\" class=\"maestro\" xmlns=\"http://www.w3.org/1999/xhtml\│
    │">":"<head><link href=\"https://cfl.dropboxstatic.com/static/css/accou│
    │nt/emails-vflCV9b0W.css\" type=\"text/css\" crossorigin=\"anonymous\" │
    │rel=\"stylesheet\" />"}                                               │
    ├──────────────────────────────────────────────────────────────────────┤
    │{"<!DOCTYPE html><html lang=\"en\" xmlns:fb=\"http://ogp.me/ns/fb#\" x│
    │ml:lang=\"en\" class=\"maestro\" xmlns=\"http://www.w3.org/1999/xhtml\│
    │">":"<link href=\"https://cfl.dropboxstatic.com/static/css/deprecated/│
    │components/multiaccount_login_modal-vflNhUM8J.css\" type=\"text/css\" │
    │crossorigin=\"anonymous\" rel=\"stylesheet\" />"}                     │
    ├──────────────────────────────────────────────────────────────────────┤
    │{"<!DOCTYPE html><html lang=\"en\" xmlns:fb=\"http://ogp.me/ns/fb#\" x│
    │ml:lang=\"en\" class=\"maestro\" xmlns=\"http://www.w3.org/1999/xhtml\│
    │">":"<link href=\"https://cfl.dropboxstatic.com/static/css/font_paper_│
    │atlas_grotesk-vflEbKJso.css\" type=\"text/css\" crossorigin=\"anonymou│
    │s\" rel=\"stylesheet\" />"}                                           │
    └──────────────────────────────────────────────────────────────────────┘
    

    要解决此问题,请尝试从DropBox获取直接下载链接(如果可能)或更改为其他存储工具 .

相关问题