Reputation: 2567
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
Upvotes: 4
Views: 3664
Reputation: 1
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.
Upvotes: 0
Reputation: 41676
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
Upvotes: 3