4
votes

I have 2 CSV files which I want to convert into a Neo4j database. They look like this:

first file:

name,enzyme
Aminomonas paucivorans,M1.Apa12260I
Aminomonas paucivorans,M2.Apa12260I
Bacillus cellulosilyticus,M1.BceNI
Bacillus cellulosilyticus,M2.BceNI

second file 

name,motif
Aminomonas paucivorans,GGAGNNNNNGGC
Aminomonas paucivorans,GGAGNNNNNGGC
Bacillus cellulosilyticus,CCCNNNNNCTC

As you can see the common factor is the Name of the organism and the. Each Organism will have a few Enzymes and each Enzyme will have 1 Motif. Motifs can be same between enzymes . I used the following statement to create my database:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
MATCH (o:Organism { name: csvLine.name}),(e:Enzyme { name: csvLine.enzyme})
CREATE (o)-[:has_enzyme]->(e)

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop/n_m.csv" AS csvLine
MATCH (o:Organism { name: csvLine.name}),(m:Motif { name: csvLine.motif})
CREATE (o)-[:has_motif]->(m) 

However I keep getting the error Cannot merge node using null property value for name (Failure when processing URL 'file:C:/Users/Desktop/n_e.csv' on line 2. No rows seem to have been committed. Note that this information might not be accurate.). I googled the issue but got no working solution to this. I made sure my CSV is "vanilla" csv (no spaces, only comma separated). but I keep getting this problem. i am using the 2.1.3 version of Neo4j. Any help will be greately appreciated.

File 1: n_e.csv File 2: n_m.csv

2
Hello letsc, I also get this kind of error. What solved it for me was that I inserted also FIELDTERMINATOR ','. Hope it helps with your problem.Gondil

2 Answers

3
votes
  1. Update to 2.1.5
  2. read this blog post on how to check that your data is read correctly.
  3. Also you might check that you don't have windows newlines or an UTF 2-byte file preamble
  4. check that you have an index for :Organism(name) and :Enzyme(name) and :Motif(name) in place

In general try this and check the outputs:

LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
RETURN csvLine
LIMIT 5

LOAD CSV WITH HEADERS FROM "file:C:/Users/Desktop.n_e.csv" AS csvLine
RETURN csvLine.name,csvLine.enzyme 
LIMIT 5
0
votes

In my case the reason was the spaces in header line. For example, a CVS file:

Name, Surname, City
Jan, Kowalski, Gdansk

so, the Name was imported fine, but the Surname was not recognized (was null), as was space between comma and Surname, etc. After removing it, it started working.