cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Load data from CSV

vsanghavi
Node

2X_a_a72ad8c85e6a208ef74a7f8ed39bf38a9d1e6e14.png

Hi
I am trying to load the CSV using the following query.

load csv with headers from "file:///test.csv" as line
merge(a:Client{Name:line.TradingMember})
merge (b:Company{Name:line.WorksFor, ISIN:line.ISIN,Security:line.Security})
merge (a)-[:Employee]-(b)
with b,line
match (a:Client),(b:Company)
where b.Name=line.OwnsSymbol
merge (a)-[:Has_DebitCard{asd:line.Volume}]->(b)

I got this as output
2X_8_84979c7fc5eea5eddcb49dd9e2ec6fa6f7dc54b6.png
The expected output is that the OwnsSymbol column should be used as Company Name rather than creating a new node to form a relationship with the Client node as Has_Debit. The Mapping of Has_Debit is wrong according to the CSV.

2 REPLIES 2

hey,
Im facing the same kind of problem. I'm trying to dynamically match similar string and make a relationship without creating new node !!!

yyyguy
Graph Buddy

Hello,

You should modify your query as follows:

load csv with headers from "file:///test.csv" as line
merge(a:Client{Name:line.TradingMember})
merge (b:Company{Name:line.WorksFor, ISIN:line.ISIN,Security:line.Security})
merge (a)-[:Employee]-(b)
with a, b,line
match (b:Company {Name: line.OwnsSymbol})
merge (a)-[:Has_DebitCard{asd:line.Volume}]->(b)

This is where the issue lies. You want to bring forward the results of 'a' and include these results in your WITH statement. Otherwise, you are doing a new separate query with the MATCH (a:Client) statement.

-yyyguy