Reading Relationships As Line From CSV

Please, I am trying to import a csv file into Neo4j desktop, which has a column that already defines the relationship between the two nodes in the file. Below is a simple example of what I am talking about:

Name       Action         Movie
Tom        DIRECTED       Mega Day
Harry      PRODUCED       Falling Sun

Now, I want to read in the csv file as line with cypher. Is it possible to read the relationship column as line as well, such that the nodes are automatically connected with each other via the relationship between them per line?

Hi Gary. Thanks again for your suggestion. While I still think it is the solution, I tried to implement it with my actual dataset, but got an error. Here is my actual cypher statement:

load csv with headers from "file:///pixar.csv" as line

merge (p:Person{name:line.name})

merge (m:Movie{title:line.film})

with p, m, line

call {

with p, m, line

with p, m, line

where line.role\_type \= "DIRECTED"

merge (p)-\[:DIRECTED\]->(m)    

}

call {

with p, m, line

with p, m, line

where line.role\_type \= "PRODUCED"

merge (p)-\[:PRODUCED\]->(m)    

}

call {

with p, m, line

with p, m, line

where line.role\_type \= "WAS\_SCREEN\_WRITER\_FOR"

merge (p)-\[:WAS\_SCREEN\_WRITER\_FOR\]->(m)    

}

call {

with p, m, line

with p, m, line

where line.role\_type \= "WAS\_STORY\_WRITER\_FOR"

merge (p)-\[:WAS\_STORY\_WRITER\_FOR\]->(m)    

}

call {

with p, m, line

with p, m, line

where line.role\_type \= "PERFORMED\_SOUNDTRACK\_FOR"

merge (p)-\[:PERFORMED\_SOUNDTRACK\_FOR\]->(m)    

}

Running that gave me the error message below:

Neo.ClientError.Statement.SyntaxError

Query cannot conclude with CALL (must be RETURN or an update clause) (line 29, column 1 (offset: 703))
"call {"

Please, what do you think?

This solution works if you know the relationships so you can write the query for them. But in my case the relationships are unknown in advance, so how can I modify the query to handle this? So I guess something like

load csv with headers from "file:///Book1.csv" as line
merge(a:Actor{name: line.Name})
merge(m:Movie{title: line.Movie})
with a, m, line
call {
with a, m, line
with a, m, line
merge(a)-[:line.action]->(m)
}

but this doesn't work as is. Any help appreciated!

As a corollary, my csv file also has some properties for the relationship so ideally I need something like

... merge(a)-[:line.action {property:line.property}]->(m)

where property is the property name from the csv header row, and line.property is the specified value on the data line. Is such a thing possible?

Thank you!

I face the same problem. Is there any solution for this?