Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-26-2020 08:34 PM
I have a csv which is in matrix form and i want to extract values of those
csv file is like:
|Regulon_ID | SelfSufficiencyInGrowthSignals | InsensitivityToAntigrowthSignals|
|R-0 | 1 | 1|
I want to extract values of this eg: R-0 and SelfSufficiencyInGrowthSignals as value 1
i have node Regulon and mark
Regulon node contains Regulon_ID which is R-0,R-1
and second node mark which contains column names of this csv ----------eg.SelfSufficiencyInGrowthSignals,InsensitivityToAntigrowthSignals
how can i create relationship with values .
02-27-2020 12:20 AM
Hi kanthalepriyanka, welcome!
If I understand what do you want to do, I suggest something like this:
LOAD CSV WITH HEADERS FROM 'file:///fileName.csv' AS line FIELDTERMINATOR '|'
MATCH (r:Regulon{Regulon_ID: line.Regulon_ID}), (s:SelfSufficiencyInGrowthSignals{name: 'SelfSufficiencyInGrowthSignals'}), (i:InsensitivityToAntigrowthSignals{name: 'InsensitivityToAntigrowthSignals'})
CREATE (r)-[:HAVE {value: line.SelfSufficiencyInGrowthSignals}]->(s)
CREATE (r)-[:HAVE {value: line.InsensitivityToAntigrowthSignals}]->(i)
02-27-2020 08:32 PM
hey
this makes two different relationship i want to create only one relationship .
02-28-2020 04:53 AM
Hi Priyanka,
Your requirement is not very clear. However if you looking just one relationship then try
LOAD CSV WITH HEADERS FROM 'file:///fileName.csv' AS line
create (r:Regulon{Regulon_ID: line.Regulon_ID})
create (s:Mark{name: line.SelfSufficiencyInGrowthSignals})
create (i:Mark{name: line.InsensitivityToAntigrowthSignals})
MATCH (m:Mark)
WITH m.name as name, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
Create (r:Regulon)-[:HAVE ]->(m:Mark)
02-28-2020 10:40 AM
Instead of creating nodes and immediately merging, you can create the node in one instance;
merge (r:Regulon{Regulon_ID: line.Regulon_ID})
merge (s:Mark{selfsufficieny: line.SelfSufficiencyInGrowthSignals, insensitivity: line.InsensitivityToAntigrowthSignals})
merge (r:Regulon)-[:HAVE ]->(m:Mark)
03-01-2020 09:28 PM
yeah !!! how to iterate column of csv in neo4j without giving conditions?
03-01-2020 11:04 PM
Sorry,, did not understand
03-01-2020 11:12 PM
LOAD CSV WITH HEADERS FROM 'file:///Lin.csv' AS line
MATCH (r:regulons)
WHERE r.Regulon_ID=line.Regulon_ID
MATCH (h:marks) WHERE (h.hallmark = 'SelfSufficiencyInGrowthSignals')
FOREACH (ignoreMe in CASE
WHEN exists(h.hallmark) THEN [line.SelfSufficiencyInGrowthSignals]
ELSE [line.InsensitivityToAntigrowthSignals] END| CREATE (r)-[:REGULON_TO_HALLMARK { value1:line.SelfSufficiencyInGrowthSignals
}]->(h))
I made this relationship but this relationship is only for SelfSufficiencyInGrowthSignals i want to add InsensitivityToAntigrowthSignals also in this relationship .so how will i be able to do this???
03-01-2020 11:36 PM
Please try this
MATCH (h:marks) WHERE (h.hallmark = 'SelfSufficiencyInGrowthSignals')
FOREACH (ignoreMe in CASE
WHEN h.hallmark = 'SelfSufficiencyInGrowthSignals' CREATE (r)-[:REGULON_TO_HALLMARK { value1:line.SelfSufficiencyInGrowthSignals
}]->(h)
When h.hallmark = 'InsensitivityToAntigrowthSignals' CREATE (r)-[:REGULON_TO_HALLMARK { value1:line.InsensitivityToAntigrowthSignals
}]->(h) END)
03-02-2020 12:00 AM
OK i will try this and let u know
03-02-2020 09:49 PM
I DID THE QUERY WHICH WORKED FOR ME
LOAD CSV WITH HEADERS FROM 'filename' AS line
MATCH (r:regulons)
WHERE r.Regulon_ID=line.Regulon_ID
MATCH (h:marks) WHERE (h.mark <> keys(line))
FOREACH (ignoreMe in CASE
WHEN exists(h.mark) AND line[h.mark] THEN [line]
ELSE END | CREATE (r)-[:REGULON_TO_MARKS{value:line[h.mark]}]->(h))
WHICH WILL CREATE ONE RELATIONSHIP and TAKE VALUE of it in edge
All the sessions of the conference are now available online