Syntax error

(Jeffreylm) #1

Dear Everyone,

I am trying to import a CSV, but there is a syntax error that I am not seeing. After 20 mins of re-reading it, I've now turned to the community.

I have added the error as a screenshot attachment.

(DKumar) #2

can you check if there are any special characters in the csv file ?
also check if the csv is of good data quality.

(Jeffreylm) #3

The email adres field has "@". That is about it. It is an import from Filemaker. It is one table.

(Jeffreylm) #4

Also the telephone nr field has "-" in it. And the URL field is https://

(Andrew Bowman) #5

Looks like your fields have spaces in them (such as sup.Company Name), that doesn't parse well.

You need to encase your entire field name with backticks:

sup.`Company Name`

and so on for the rest of your fields.

(Jeffreylm) #6

Hello Andrew,

You advice worked. So I am a step further. I have an attachment that show that I am getting one nore with all the properties added to the node from the CSV, instead of a series of nodes.

Why isn't my cypher query not creating a node for each record in the CSV? (See attachment)

(Andrew Bowman) #7

You'll want to read up on how MERGE works. MERGE Is like a MATCH, and if the match fails, a CREATE.

When you do MERGE(sup:Suppliers), for the first row this will create a new :Suppliers node, since (I'm guessing) there aren't any before running this.

For every subsequent row, the MERGE is matching on that single node that was created with the first row, so no other nodes ever get created, you keep on overwriting the properties of the single node.

What you want to do instead is MERGE using the property or properties that are unique for the node (and you should have an index to go with this or it will get increasingly expensive.

So in your case, I'm guessing CompanyID ought to be unique, so create a unique constraint on :Suppliers(CompanyID), and use that unique property in the MERGE, then use ON CREATE SET for the rest:

MERGE (sup:Suppliers {CompanyID:line.CompaniesIDpk})

(Jeffreylm) #8

Hello Andrew,

Really thank you for taking the time to explain this. Have been reading and try different things for three days, and just finally decided to post the question here.

What you said worked perfectly. I read all the details about merges and such, but the missing part was how it acted in the presence of a constraint. The constraint is the missing key to this. That wasn't clear to me whilst reading all the parts separately.

Are there any books you would highly recommend that not only shows you the cypher language, but also the gotchas and how combining them makes them work totally different?

Also, is there a good resource showing the migration from a RDMS to a Neo4j database?
I have seen a few things on youtube, but i'm being bombarded by all other things besides specifically the steps to get it it over with rejoining the tables and such.

Kind regards,