cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.

How to import a list of key-value pairs of properties from multiple JSON files?

kasipasi
Node Clone

Hello,

I have nodes with node label Tracepart, each of those nodes has a property called  "catalogPathID".

Now I have +1000 json files in a folder that I would like to load into the db and the plan is to create Product nodes and create a parent relationships with the Tracepart nodes by mapping with the catalogPathName (see below a example code from one of the json files). After I also want to create nodes for all the Parts nodes and create another parent relationships with its father, the Product.

As you can see also to make this even more difficult, the properties are different for product to product and also for part to part, see example 1 and 2. One thing that is always the same for the Product is  

catalogPathID and productID, with that we can create the relationship first between Tracepart nodes with the Product nodes and after the Product nodes and its children in the array the Part nodes.

I have the following challenges:

1. How to read multiple key-value pairs (the properties as I cannot hard code the property names as each product and part has different property names)?
2. How to read multiple json files from a folder?
3. How to loop through an array of children in a json file (the partNumbers array each Product has)?

Example 1 unique properties for the Product node and its children (Part nodes):

 

    {
        "Material": "Bronze",
        "catalogPathID": "TRACEPARTS:TP01002003003",
        "catalogPathName": "Spherical plain bearings",
        "productID": "10-25012006-080342",
        "productName": "Bearing type C, spherical",
        "manufacturer": "AMES Sintered Metallic Components",
        "productURL": "https://www.traceparts.com/en/product/ames-sintered-metallic-components-bearing-type-c-spherical?CatalogPath=TRACEPARTS%3ATP01002003003&Product=10-25012006-080342",
        "productImage3Dmodel": "",
        "productImagePicture": "https://cdn.tracepartsonline.net/PartsDefs/Production/AMES/10-25012006-080342/Pictures/10-25012006-080342L.gif",
        "productImageDocument": "https://cdn.tracepartsonline.net/PartsDefs/Production/AMES/10-25012006-080342/Documents/type_C.gif",
        "partNumbers": [
            {
                "Index": "1",
                "Selector": "1",
                "Inner \u00d8 (mm)": "4",
                "Sphere \u00d8 (mm)": "10",
                "Length (mm)": "8"
            },
            {
                "Index": "2",
                "Selector": "2",
                "Inner \u00d8 (mm)": "5",
                "Sphere \u00d8 (mm)": "12",
                "Length (mm)": "9"
            }
        ]
    }

 

Example 2 unique properties for the Product node and its children (Part nodes):

 

    {
        "Mass": "0.14 kg",
        "catalogPathID": "TRACEPARTS:TP01002003003",
        "catalogPathName": "Spherical plain bearings",
        "productID": "33-16072018-083434",
        "productName": "Angular contact spherical plain bearings",
        "manufacturer": "SKF",
        "productURL": "https://www.traceparts.com/en/product/skf-angular-contact-spherical-plain-bearings?CatalogPath=TRACEPARTS%3ATP01002003003&Product=33-16072018-083434",
        "productImage3Dmodel": "",
        "productImagePicture": "https://cdn.tracepartsonline.net/PartsDefs/Production/SKF/33-16072018-083434/Pictures/33-16072018-083434L.gif",
        "productImageDocument": "https://cdn.tracepartsonline.net/PartsDefs/Production/SKF/33-16072018-083434/Documents/bla_001_1.PNG",
        "partNumbers": [
            {
                "Index": "1",
                "Selector": "1",
                "Part number": "GAC 25 F",
                "Bore \u00d8 :<br />d (mm)": "25",
                "Outside \u00d8 :<br />D (mm)": "47",
                "Nominal width :<br />T (mm)": "15",
                "Angle of tilt :<br />a (\u00b0)": "3.5",
                "Raceway \u00d8 inner ring :<br />dk (mm)": "42",
                "Width inner ring :<br />B (mm)": "15",
                "Width outer ring :<br />C (mm)": "14",
                "Chamfer dimension bore/large side face :<br />r1min. (mm)": "0.6",
                "Chamfer dimension bore/small side face :<br />r2min. (mm)": "0.3",
                "Distance sphere \u00d8 centre - large inner ring side face :<br />s (mm)": "0.6",
                "Abutment \u00d8 shaft, small inner ring side face :<br />damax (mm)": "29",
                "Abutment \u00d8 shaft, large inner ring side face :<br />dbmax. (mm)": "39",
                "Abutment \u00d8  housing, large outer ring side face :<br />Damin. (mm)": "34",
                "Abutment \u00d8 housing, small outer ring side face :<br />Dbmin. (mm)": "43",
                "Fillet radius shaft, housing :<br />ramax. (mm)": "0.6",
                "Basic dynamic load rating :<br />C (kN)": "24",
                "Basic static load rating :<br />C0 (kN)": "38",
                "Specific dynamic load factor :<br />K (N/mm\u00b2)": "50",
                "Specific static load factor :<br />K0 (N/mm\u00b2)": "80",
                "Material constant :<br />KM": "480",
                "Mass plain bearing (kg)": "0.14"
            },
            {
                "Index": "2",
                "Selector": "2",
                "Part number": "GAC 30 F",
                "Bore \u00d8 :<br />d (mm)": "30",
                "Outside \u00d8 :<br />D (mm)": "55",
                "Nominal width :<br />T (mm)": "17",
                "Angle of tilt :<br />a (\u00b0)": "3.5",
                "Raceway \u00d8 inner ring :<br />dk (mm)": "49.5",
                "Width inner ring :<br />B (mm)": "17",
                "Width outer ring :<br />C (mm)": "15",
                "Chamfer dimension bore/large side face :<br />r1min. (mm)": "1",
                "Chamfer dimension bore/small side face :<br />r2min. (mm)": "0.3",
                "Distance sphere \u00d8 centre - large inner ring side face :<br />s (mm)": "1.3",
                "Abutment \u00d8 shaft, small inner ring side face :<br />damax (mm)": "35",
                "Abutment \u00d8 shaft, large inner ring side face :<br />dbmax. (mm)": "45",
                "Abutment \u00d8  housing, large outer ring side face :<br />Damin. (mm)": "39",
                "Abutment \u00d8 housing, small outer ring side face :<br />Dbmin. (mm)": "50.5",
                "Fillet radius shaft, housing :<br />ramax. (mm)": "1",
                "Basic dynamic load rating :<br />C (kN)": "30",
                "Basic static load rating :<br />C0 (kN)": "48",
                "Specific dynamic load factor :<br />K (N/mm\u00b2)": "50",
                "Specific static load factor :<br />K0 (N/mm\u00b2)": "80",
                "Material constant :<br />KM": "480",
                "Mass plain bearing (kg)": "0.21"
            }
        ]
    }

 

 This is the code I plan to run after I have imported all the Product and Part nodes into the db so relate each Product with its Tracepart catalogPathID node. Not sure if this is possible to do direct when importing the Product and Parts.

 

// Connect Traceparts with Product nodes
match(n:Traceparts)
where n.catalogPathID is not null
match(m:Product)
where m.catalogPathID = n.catalogPathID
merge (m)<-[:parent]-(n)

 

Overview of parent relationships between the node labels Tracepart, Product and Part. See Example 2 for json data above.

kasipasi_4-1665242653077.png

kasipasi_5-1665243288283.png

 

 

0 REPLIES 0