Import and merg JSON data with APOC

Hello Everyone,

I can't figure out what I am doing wrong.
I am attempting to create the following import but receive the following error (see attachment):

CALL apoc.load.json("file:/users/james/Desktop/desktop/keepa/Product_Finder.2019_10_12_Cleaned.json") YIELD value
WITH value AS v
MERGE(t:Toy {ASINnr:v.ASIN})
SET t.ProductName = v.Title,
t.Height = v.'Item: Height (cm)',
t.Length = v.'Item: Length (cm)',
t.Width = v.'Item: Width (cm)',
t.Dimension = v.'Item: Dimension (cm³)',
t.modelNr = v.Model,
t.Category = "Toys & Games",
t.SalesRank = v.'Sales Rank: Current',
t.Weight = v.'Item: Weight (g)',
t.Brand = v.Brand
RETURN t

does it work if you use subscript notation:

....
t.Length = v['Item: Length(cm)'], 
...

(of course for all accesses on v) ?

Hello Stefan,

I tried as you said and got the exact same error.
Also where can read more about subscript notations in Neo4j?
I am new to Neo4j (3-4 months)

Thank you for responding.

Kind regards

Can you try replaced the single quotes with back ticks?

CALL apoc.load.json("file:/users/james/Desktop/desktop/keepa/Product_Finder.2019_10_12_Cleaned.json") YIELD value
WITH value AS v
MERGE(t:Toy {ASINnr:v.ASIN})
SET t.ProductName = v.Title,
t.Height = v.`Item: Height (cm)`,
t.Length = v.`Item: Length (cm)`,
t.Width = v.`Item: Width (cm)`,
t.Dimension = v.`Item: Dimension (cm³)`,
t.modelNr = v.Model,
t.Category = "Toys & Games",
t.SalesRank = v.`Sales Rank: Current`,
t.Weight = v.`Item: Weight (g)`,
t.Brand = v.Brand
RETURN t
1 Like

Hello Mark,

You are razor sharp!!!!!

It worked. I just learned about using back ticks, and thought I used it, but as you clearly realized, those were single quotes. This lesson I will always remember for the rest of my career every time I use them, as I suspect it will often be the case whilst pulling in json from sites.

Hats off to you Mark.

I'm new to Neo4j, just started learning it earlier this year.

Many, many thanks.

Greetings

No worries - the error message is not particularly helpful in that respect unfortunately.

Cool, hope you're enjoying the journey so far!

1 Like

Hello Mark,

Yes, I am definitely enjoying the journey. I am coming from the world of Relational Databases, so it is mind blowing how more efficient cypher and graphs are. Just having to get use to the syntax.

I have another question. Here is the link to the post. Maybe you know how to solve this issue.
In all the tutorials I have looked at to date from people importing data, know one has ever "clean up" data . It is always imported as is, which is almost never the case in real world.

Thanks in advance.

Just replied to that one, but I'm not sure that I did anything different to what you already did!