Hi, lately I have a issue which I couldn't connect a column from my first CSV import file through a second one to the a column in the 3th CSV file,
What I mean is I have 3 CSV files, in first one a list of books and information about them in second one a list of books ID's and also writter ID's in third one we have writters information, what I want to do is create graph between book and writter also show the information about them.
Any idea?
// Create academy
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///academy.csv" AS row
CREATE (:Academy {academyID: TOINT(row.id), academyName: row.Name, cityName: row.CityItalianName});
// Create Person
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///person.csv" AS row
CREATE (:Person {personID: TOINT(row.Id), personName: row.Surname, personFamily: row.Forename, personBirth: TOINT(row.BirthDate), personDeath: TOINT(row.DeathDate), personNation: row.Nationality});
// Create Book
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///book.csv" AS row
CREATE (:Book {bookID: TOINT(row.Id), academyID: TOINT(row.AcademyIds), authorID: TOINT(row.AuthorIds), bookSubject: row.Subjects});
// Create Indexs
CREATE INDEX ON :Academy(academyID);
CREATE INDEX ON :Academy(academyName);
CREATE INDEX ON :Academy(cityID);
CREATE INDEX ON :Academy(cityName);
CREATE INDEX ON :Person(personID);
CREATE INDEX ON :Person(personName);
CREATE INDEX ON :Person(personFamily);
CREATE INDEX ON :Person(personBirth);
CREATE INDEX ON :Person(personDeath);
CREATE INDEX ON :Person(personNation);
CREATE INDEX ON :Book(bookID);
CREATE INDEX ON :Book(academyID);
CREATE INDEX ON :Book(authorID);
CREATE INDEX ON :Book(bookSubject);
// Create Relations books - persons
MATCH(b:Book)
MERGE(b.bookSubject)-[r:WRITE_BY]->(b.authorID)
return r ;
MATCH (p:Person),(b:Book)
MERGE (b)-[r:WRITE_BY]->(p)
RETURN r;
MATCH (p:Person),(a:Academy)
MERGE (p)-[r:RELATED_TO]->(a)
RETURN r;
MATCH (b:Book),(a:Academy)
MERGE (b)-[r:CONNECTED]->(a)
RETURN r;
You have many issues in your import, even before you worry about establishing relationships. For one thing, it looks like you are trying to convert an array of academy and author ID's to an int. Let's say those were not arrays. Even so, you cannot create relationships between properties on a node. Only between nodes. MERGE(b.bookSubject)-[r:WRITE_BY]->(b.authorID) makes no sense. `MERGE (b)-[:WRITE_BY]->(a:Author { personId: b.authorID}) might go in a better direction, but I'm still talking nonsense, because you'll need more graph design first.
You may have general gaps in your understanding, and should read the docs further.