Problems Importing CSV

I am trying to import my first table into Neo4j.

A very simple CSV file (sample):

SpecialtyID,Specialty,SubSpecialty
7001,Accounting
7002,Administrative Services
7003,Adult Education
7025,Consulting,Building and Construction

// Create Specialties
LOAD CSV WITH HEADERS FROM 'https://github.com/johnmillstead/pmg_connect/blob/f90605e306d54ee85c7eceba70f4fc093c8edac4/specialties.csv' AS row
MERGE (specialty:Specialty {specialtyID: row.SpecialtyID})
    ON CREATE SET specialty.specialty = row.Specialty, specialty.subSpecialty = row.SubSpecialty;

results in: Cannot merge the following node because of null property value for 'specialtyID': (:Specialty {specialtyID: null})

Try this:

MERGE (specialty:Specialty {specialtyID: toInteger(row.SpecialtyID)})
    ON CREATE SET specialty.specialty = COALESCE(row.Specialty, 'NA'), specialty.subSpecialty = COALESCE(row.SubSpecialty, 'NA');

Thanks. But that didn't work for some reason. So I simplified the dataset to make things easier. Here is what I am working with:

SpecialtyID,Specialty
7001,Accounting
7005,Art
7012,Blogging
7018,Coaching
7041,Editing
7042,Encouragement
7043,Engineering
7044,ESL
7045,Evaluation

I am using this cyper:

// Create Specialties
LOAD CSV WITH HEADERS FROM 'https://github.com/johnmillstead/pmg_connect/blob/fbec96e04c8209cb922d5b3cd31c1fd5b792acb5/specialties.csv' AS row
MERGE (specialty:Specialty {specialtyID: toInteger(row.SpecialtyID)})
    ON CREATE SET specialty.specialty = row.Specialty;

I have tried it with the coalesce and without. I have tried it with the toInteger and without.

I so desperately want to win at this game and finish the very simple project I am tasked with. Thanks for any help you can provide.

John

Hi John

In case the csv format is likely to change over a period of time then it is better to encode them as procedures and include them as libraries on your own installation.

Many thanks
Mr Sameer Sudhir G

@john6

something is amiss for if I run

LOAD CSV WITH HEADERS FROM 'https://github.com/johnmillstead/pmg_connect/blob/fbec96e04c8209cb922d5b3cd31c1fd5b792acb5/specialties.csv' AS row return row;

which should do nothing more than read the csv from github and return each row the results I get are

╒══════════════════════════════════════════════════════════════════════╕
β”‚"row"                                                                 β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•‘
β”‚{"<!DOCTYPE html>":"<html lang="en" data-color-mode="auto" data-light-β”‚
β”‚theme="light" data-dark-theme="dark">"}                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"  <head>"}                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"    <meta charset="utf-8">"}                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"  <link rel="dns-prefetch" href="https://github.giβ”‚
β”‚thubassets.com">"}                                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"  <link rel="dns-prefetch" href="https://avatars.gβ”‚
β”‚ithubusercontent.com">"}                                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"  <link rel="dns-prefetch" href="https://github-clβ”‚
β”‚oud.s3.amazonaws.com">"}                                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚{"<!DOCTYPE html>":"  <link rel="dns-prefetch" href="https://user-imagβ”‚
β”‚es.githubusercontent.com/">"}                                         β”‚
....
......
.........

which doesnt appear at all like the csv at pmg_connect/specialties.csv at f90605e306d54ee85c7eceba70f4fc093c8edac4 Β· johnmillstead/pmg_connect Β· GitHub.

If you run the same LOAD CSV do yo get similar results?
I think the issue is you have the wrong URL for if you run

LOAD CSV WITH HEADERS FROM 'https://raw.githubusercontent.com/johnmillstead/pmg_connect/f90605e306d54ee85c7eceba70f4fc093c8edac4/specialties.csv' AS row return row.SpecialtyID, row.Specialty, row.SubSpecialty;

note the different URL, namely https://raw......... then now I get more expected results and as

╒═════════════════╀════════════════════════════════════════════╀═════════════════════════════════════╕
β”‚"row.SpecialtyID"β”‚"row.Specialty"                             β”‚"row.SubSpecialty"                   β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•ͺ════════════════════════════════════════════β•ͺ═════════════════════════════════════║
β”‚"7001"           β”‚"Accounting"                                β”‚null                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚"7002"           β”‚"Administrative Services"                   β”‚null                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚"7003"           β”‚"Adult Education"                           β”‚null                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚"7004"           β”‚"Appropriate Technologies"                  β”‚null                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚"7005"           β”‚"Art"                                       β”‚null                           
....
.......
...........

and to which running

LOAD CSV WITH HEADERS FROM 'https://raw.githubusercontent.com/johnmillstead/pmg_connect/f90605e306d54ee85c7eceba70f4fc093c8edac4/specialties.csv' AS row MERGE (specialty:Specialty {specialtyID: row.SpecialtyID})
    ON CREATE SET specialty.specialty = row.Specialty, specialty.subSpecialty = row.SubSpecialty;

results in

Added 149 labels, created 149 nodes, set 324 properties, completed after 136 ms.
1 Like

Thank you so much! I appreciate it. I learned something valuable.

1 Like