I want to create a simple DB using some CSV files, like this: attore.csv, film.csv, recita.csv.
I created successfully the nodes with the label Attore and Film, simple files like this:
attore.csv:
nome
nome1
nome2
nome3
film.csv
titolo
titolo1
titolo2
titolo3
and I was trying to create the relationship between them using recita.csv, in which each row is:
attore, film
Obv my primary key should be Attore(nome) and Film(titolo). I've been looking for so much time, I found many codes but no one is working, every try I made just run for something like an hour.
This is what I did:
I created the film nodes:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///film.csv" AS row
CREATE (n:Film)
SET n = row, n.titolo = (row.titolo), n.durata = (row.durata),
n.genere = (row.genere), n.anno = (row.anno), n.descrizione =
(row.descrizione), n.regista = (row.regista),
n.studio_cinematografico = (row.studio_cinematografico)
Then I created the attore nodes:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///attore.csv" AS row
CREATE (n:Attore)
SET n = row, n.nome = (row.nome)
And then, after so much try I thought this was the exact way to create relationship, but didn't work:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///recita.csv" AS row
MATCH (attore:Attore {nome: row.attore})
MATCH (film:Film {titolo: row.film})
MERGE (attore)-[:RECITA]-(film);
I hope that someone could tell me the right way to create relationship, thanks.
EDIT: Examples of how are structured my files attore.csv:
nome
Brendan Fraser
Bett Granstaff
Leslie Nielsen
Martina Gedeck
Martin Sheen
film.csv:
titolo durata genere anno descrizione regista studio_cin
Mortdecai 80 Action 2015 *something* David Koepp Liongate
recita.csv:
attore film
Johnny Depp Mortdecai
Jason Momoa Braven