Load CSV does not set all properties

Hi All,
I am evaluating using memGraph for our new project, mainly having to store graph/hierarchial data. The data set by itself is small to medium sized. I 've checked out the basic cypher commands which worked fine. Now I am trying to import some data into the DB using LOAD CSV cypher command where in I am hitting the issue.

Env details: Docker on Mac

docker run -it -p 7687:7687 -p 7444:7444 -p 3000:3000 -v mg_lib:/var/lib/memgraph memgraph/memgraph-platform

Steps to reproduce:

  1. Run memgraph using docker command:
    docker run -it -p 7687:7687 -p 7444:7444 -p 3000:3000 -v mg_lib:/var/lib/memgraph memgraph/memgraph-platform
  2. Try LOADING CSV data into DB using the following commands:
1. LOAD CSV FROM "/deptt-deDup.csv"  WITH HEADER AS row
       -> CREATE (d:Department)
       -> SET d.code = row.code, d.name = row.name, d.id = row.id;
Empty set (round trip in 0.001 sec)
INFO: It's important to note that the parser parses the values as strings. It's up to the user to convert the parsed row values to the appropriate type. This can be done using the built-in conversion functions such as ToInteger, ToFloat, ToBoolean etc.
77 labels have been created.
77 nodes have been created.
231 properties have been updated.
2. LOAD CSV FROM "/deptt-deDup.csv"  WITH HEADER AS row
       -> CREATE (d:Department{ code: row.code, name: row.name });
3. LOAD CSV "/commodity-Dedup.csv"  WITH HEADER AS row
       -> MERGE (c:Commodity{code: row.code, name: row.name});
4. memgraph> LOAD CSV FROM "/deptt-deDup.csv"  WITH HEADER AS row
       -> MERGE (d:Department{code: row.code})
       -> SET d.code = row.code, d.name = row.name;
Empty set (round trip in 0.266 sec)
INFO: It's important to note that the parser parses the values as strings. It's up to the user to convert the parsed row values to the appropriate type. This can be done using the built-in conversion functions such as ToInteger, ToFloat, ToBoolean etc.
77 labels have been created.
77 nodes have been created.
154 properties have been updated.

For some reason I am not able to upload the CSV file so am pasting a small snippet of the file below:
code,name,id
0,GROC-ALL OTHER ,0
1,PET ,1
2,SOFT DRINKS ,2
3,BABY ,3
4,SPIRITS ,4

  1. Query for the nodes using Cypher commands:
MATCH(d:Department)
return d
  1. Note that the node has only the name property. It does not have the id or the code properties

Appreciate any inputs.

Thanks

:bug: Bug Report

Description

(A clear and concise description of what the bug is.)

Steps to reproduce

(Write your steps here:)

  1. Step 1…
  2. Step 2…
  3. Step 3…

Expected behavior

(Write what you thought would happen.)

Actual behavior

(Write what happened. Add full console log messages and screenshots, if applicable.)

Your environment

  • Memgraph version used
  • Operating system and version (e.g., Ubuntu 20.04.2 LTS)

Hi @enthu_learner. I copied the data you provided me and saved it as data.csv:

code,name,id
0,GROC-ALL OTHER ,0
1,PET ,1
2,SOFT DRINKS ,2
3,BABY ,3
4,SPIRITS ,4

Then I ran:

LOAD CSV FROM "data.csv"  WITH HEADER AS row
CREATE (d:Department)
SET d.code = row.code, d.name = row.name, d.id = row.id;

After that, I ran

MATCH (n:Department)
RETURN n.code, n.name, n.id;

like you suggested. I end up with 5 nodes with all properties.

So, I am not sure what exactly happened and if you could provide more info or try it out again, it would be best. The only thing I noticed is strange in your steps to reproduce is that you are first loading from /deptt-deDup.csv and you end up with 77 labels and 231 properties. After that, you again load from the same file and just create nodes without their id property. Such action is going to create new 77 nodes with the same label but without id properties. Then, you are loading from a totally different CSV file (/commodity-Dedup.csv) and merging those Commodity nodes (they don’t have id property). In the end, you are again loading from the CSV file as before and merging nodes and setting their values (again no id property). So, it would be helpful if you could tell me what do you want to import and how does you data model look like to import properly. It makes sense that some of your properties are empty based on the code you provided, like I explained earlier.