简体   繁体   中英

Uploading CSV in neo4j

I am trying to upload the following csv ( https://www.dropbox.com/s/95j774tg13qsdxr/out.csv?dl=0 ) file in to neo4j by following command

LOAD CSV WITH HEADERS FROM
  "file:/home/pavan637/Neo4jDemo/out.csv"
  AS csvimport
match (uniprotid:UniprotID{Uniprotid: csvimport.Uniprot_ID})

merge (Prokaryotes_Proteins: Prokaryotes_Proteins{UniprotID: csvimport.DBUni, ProteinID: csvimport.ProteinID, IdentityPercentage: csvimport.IdentityPercentage, AlignedLength:csvimport.al, Mismatches:csvimport.mm, QueryStart:csvimport.qs, QueryEnd: csvimport.qe, SubjectStrat: csvimport.ss, SubjectEnd: csvimport.se, Evalue: csvimport.evalue, BitScore: csvimport.bs})

merge (uniprotid)-[:BlastResults]->(Prokaryotes_Proteins)

I used "match" command in the LOAD CSV command in order to match with the "Uniprot_ID's" of previously loaded CSV.

I have first loaded ReactomeDB.csv ( https://www.dropbox.com/s/9e5m1629p3pi3m5/Reactomesample.csv?dl=0 ) with the following cypher

    LOAD CSV WITH HEADERS FROM
  "file:/home/pavan637/Neo4jDemo/Reactomesample.csv"
  AS csvimport
merge (uniprotid:UniprotID{Uniprotid: csvimport.Uniprot_ID})

merge (reactionname: ReactionName{ReactionName: csvimport.ReactionName, ReactomeID: csvimport.ReactomeID})

merge (uniprotid)-[:ReactionInformation]->(reactionname)

into neo4j which was successful.

Later on I am uploading out.csv

From both the CSV files, Uniprot_ID columns are present and some of those ID's are same. Though some of the Uniprot_ID are common, neo4j is not returning any rows.

Any solutions Thanks in Advance

Pavan Kumar Alluri

Just a few tips:

  • only use ONE label and ONE property for MERGE
  • set the others with ON CREATE SET ...
  • try to create nodes and rels separately, otherwise you might get into memory issues
  • you should be consistent with your spelling and upper/lowercase of properties and labels, otherwise you will spent hours in debugging (labels, rel-types and property-names are case-sensitive)
  • you probably don't need merge for relationships, create should do fine

for your statement:

CREATE CONSTRAINT ON (up:UniprotID) assert pp.Uniprotid is unique;
CREATE CONSTRAINT ON (pp:Prokaryotes_Proteins) assert pp.UniprotID is unique;

USING PERIODIC COMMIT 10000
LOAD CSV WITH HEADERS FROM "file:/home/pavan637/Neo4jDemo/out.csv" AS csvimport
merge (pp: Prokaryotes_Proteins {UniprotID: csvimport.DBUni})
  ON CREATE SET pp.ProteinID=csvimport.ProteinID, 
                pp.IdentityPercentage=csvimport.IdentityPercentage, ...
;

LOAD CSV WITH HEADERS FROM "file:/home/pavan637/Neo4jDemo/out.csv" AS csvimport
match (uniprotid:UniprotID{Uniprotid: csvimport.Uniprot_ID})
match (pp: Prokaryotes_Proteins {UniprotID: csvimport.DBUni})
merge (uniprotid)-[:BlastResults]->(Prokaryotes_Proteins);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM