Import a data into Neo4j from csv file

Hi All, Here is the link of my problem please check this and provide me the answer...

Can you please post your tried snippet script thus far?

LOAD CSV WITH HEADERS FROM "file:///Masters.csv" AS data
WITH data

CREATE (organization:Organization {id:data.id, name:"Technoweaving"})
CREATE (asset:Asset {Id: data.AssetId, description:data.AssetDescription })
CREATE (role:Role {Role:data.Role})
CREATE (control:Control {controlId:data.CID, description:data.CDesc, category:data.ControlCategory, nature:data.ControlNature})
CREATE (security:Security {attribute:"CIA"})
CREATE (vulnerability:Vulnerability {description:data.VD})
CREATE (threats:Threats {name:data.Threats})
MERGE (organization)-[:HAS]->(asset)<-[:RESPONSIBLE_FOR]-(role)
MERGE (asset)-[:REQUIRES]->(security)
MERGE (threats)-[:AFFECTS]->(security)
MERGE (threats)-[:THREATENS]->(asset)
MERGE (asset)<-[:IMPLEMENTS_TO]-(control)
MERGE (control)-[:MITIGATE]->(vulnerability)
MERGE (threats)-[:EXPLOITS]->(vulnerability)

I think the problem would be easier if the blank cells contained the values from the cell above. Then use MERGE to prevent cell duplication.

(If you can't do that, you might want to try using a procedural/functional language like Python to work on one row at a time serially.)

I found one way to debug imports, is to instead doing any CREATE or MERGE, just RETURN the data.field values. When the result looks good, then replace the RETURNs with CREATE or MERGE. That way, you can build the import code incrementally.

Hi, clem as i have lot of data in excel sheet so how can i do this for all the data ?

What I would do:
Export the data to .CSV
Write a utility to fill in the missing values using the previous line
Write to a new .CSV file
then import the .CSV

I'm not sure how the Excel file got generated in the first place, but perhaps you can go back to the original source and have them redo the data without empty cells.

Q. Data shows three rows with first row all columns have values. Row 2 and 3 have values from field 4 onwards. How the data looks in row 4?

Let me know the data pattern in your file. This may help to design the process.

Hi @syedsibtainshahbaz,
Can a field between 3 and 4 can be added for levels ?? something like below ??

1->2->3->Level_1->4->7
Level_2->5->8
Level_3->6->9

if not, are you using a multiindex pivot or is this a CUBE output ???

can you apply validation check based on param value and if the param value does not exists then do a MATCH to get the last created nodes of field1, field2, field3 then merge the nodes and relationships of field4 and field5.

Look in my senario I have a data in my excel sheet and the data is linked with each other in order like the image above. field 3 contains their assossiative data which is linked with other. This data is like hierarchical structure

I have a very similar issue and it boggles the mind that we would have such an interesting and sophisticated program that cannot handle an empty csv entry.

Every csv that I can ever remember doing anything with had from one to thousands of empty entities. "Just write a small program to duplicate data and merge it afterwards" doesn't sound logical (although it must be) and does sound dangerous.

Us Neo-phytes require either some hand-holding, or a more robust and "normal" data intake method to help everyone bridge the gap between cells and nodes. Thanks!

Hi @syedsibtainshahbaz and @ogoecke,

I have created a sample python notebook project to load the data into neo4j.

Let me know if you have any questions.