cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Importing json file from local machine syntax using apoc

soorya
Node Link

This is the json that I want to import into the neo4j which is in a file in my local machine.
{
"products":[{
"item":{
"item_no": ,
"brand": ,
"product_description": ,
"color": ,
"size": ,
"price": ,
"team": ,
"player": ,
"event": ,
"isHotMarket":

	},
	"merch":{
		"class1": ,
		"class2": ,
		"class3": ,
		"class4": ,
		"class5": ,
		"class6": ,
		"productStyle": ,
		"classdescription"
			
	},
	"SKU":{
		"skuId":,
		"DSC": ,
		"DSC1": ,
		"DSC2": ,
		"DSC3": 
		"sku_Title": ,
		"vendor_sku": ,
		"ups":,
		"vendor_name":
	}
}]

}

I have tried

CALL apoc.load.json("file:/C:/Users/Soorya/Downloads/NBA/product.json") YIELD value
UNWIND value.item AS item
RETURN item.item_no, item.brand, item.color

in which i am getting the error

Neo.ClientError.Procedure.ProcedureCallFailed

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure apoc.load.json: Caused by: java.lang.RuntimeException: Can't read url or key file:/C:/Users/Soorya/.Neo4jDesktop/neo4jDatabases/database-8fcba9f0-f507-4e04-b15c-9b84bf2eb02a/installation-3.5.9/import/C:/Users/Soorya/Downloads/NBA/product.json as json: C:\Users\Soorya.Neo4jDesktop\neo4jDatabases\database-8fcba9f0-f507-4e04-b15c-9b84bf2eb02a\installation-3.5.9\import\C:\Users\Soorya\Downloads\NBA\product.json (The filename, directory name, or volume label syntax is incorrect)

Please help!

Thanks
Soorya

1 REPLY 1

paulare
Graph Buddy

Hi,

Your JSON file is not valid, i suggest to use https://jsonlint.com/ or some other tool to validate JSON

I did some changes to this JSON file:

{
	"products": [{
		"item": {
			"item_no": "1",
			"brand": "test_brand",
			"product_description": "",
			"color": "red",
			"size": "",
			"price": "",
			"team": "",
			"player": "",
			"event": "",
			"isHotMarket": ""
		},
		"merch": {
			"class1": "",
			"class2": "",
			"class3": "",
			"class4": "",
			"class5": "",
			"class6": "",
			"productStyle": "",
			"classdescription": ""

		},
		"SKU": {
			"skuId": "",
			"DSC": "",
			"DSC1": "",
			"DSC2": "",
			"DSC3": "",
			"sku_Title": "",
			"vendor_sku": "",
			"ups": "",
			"vendor_name": ""
		}
	}]
}
CALL apoc.load.json("product.json") YIELD value
UNWIND value.products as products
WITH products.item as item
RETURN item.color, item.item_no, item.brand

The result will be:

╒════════════╤══════════════╤════════════╕
│"item.color"│"item.item_no"│"item.brand"│
╞════════════╪══════════════╪════════════╡
│"red" │"1" │"test_brand"│
└────────────┴──────────────┴────────────┘