Hello guys,
Today I am loading a sample database from Kaggle. My intention is to follow the twitch series "Building Web Applications with Neo4j and Typescript" (@adam_cowley). So, I forked the project from Github, downloaded data from Kaggle, installed my Neo4j Desktop. All good, all set.
However, when loading the 1st dataset into neo4j, using the following commands
:auto
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM 'file:///movies_metadata.csv' AS row
MERGE (m:Movie {id: toInteger(row.id)})
SET m += row {
.overview,
.imdb_id,
.title,
.poster_path,
.backdrop_path,
.original_title,
.original_language,
.tagline,
.status,
.homepage,
runtime: toFloat(row.runtime),
release_date: date(row.release_date),
revenue: toFloat(row.revenue),
popularity: toFloat(row.popularity),
average_vote: toFloat(row.vote_average),
vote_count: toInteger(row.vote_count),
budget: toInteger(row.budget)
}
FOREACH (_ IN CASE WHEN row.original_language IS NOT NULL THEN [1] ELSE [] END |
MERGE (l:Language {id: row.original_language})
MERGE (m)-[:ORIGINAL_LANGUAGE]->(l)
)
FOREACH (_ IN CASE WHEN row.video = 'True' THEN [1] ELSE [] END | SET m:Video )
FOREACH (_ IN CASE WHEN row.adult = 'True' THEN [1] ELSE [] END | SET m:Adult )
FOREACH (language IN apoc.convert.fromJsonList(row.spoken_languages) |
MERGE (l:Language {id: language.iso_639_1}) ON CREATE SET l.name = language.name
MERGE (m)-[:SPOKEN_IN_LANGUAGE]->(l)
)
FOREACH (country IN apoc.convert.fromJsonList(row.production_countries) |
MERGE (c:Country {id: country.iso_3166_1}) ON CREATE SET c.name = country.name
MERGE (m)-[:PRODUCED_IN_COUNTRY]->(c)
)
FOREACH (genre IN apoc.convert.fromJsonList(row.genres) |
MERGE (g:Genre {id: genre.id}) ON CREATE SET g.name = genre.name
MERGE (m)-[:IN_GENRE]->(g)
)
FOREACH (company IN apoc.convert.fromJsonList(row.production_companies) |
MERGE (c:ProductionCompany {id: company.id}) ON CREATE SET c.name = company.name
MERGE (m)-[:PRODUCED_BY]->(c)
)
FOREACH (collection IN CASE WHEN apoc.convert.fromJsonMap(row.belongs_to_collection) IS NOT NULL THEN [apoc.convert.fromJsonMap(row.belongs_to_collection)] ELSE [] END |
MERGE (c:Collection {id: collection.id}) ON CREATE SET c += collection
MERGE (m)-[:IN_COLLECTION]->(c)
);
I get this error message:
Cannot merge node using null property value for id (Failure when processing file '/C:/Users/Renato/.Neo4jDesktop/neo4jDatabases/database-efd6656e-a0a8-4575-b51e-bc8fe30c50c9/installation-4.1.0/import/movies_metadata.csv' on line 19732.)
My approach was to identify line 19732 (and to process it alone). And, for my big surprise, it was loaded smoothly. So I tried once again, the entire dataset and again the error message appeared to me. This time I decided to load from line 19730 to 19735, and they were loaded just fine.
Now I'm stuck, I'm very confused with this unexpected behavior of LOAD CV. It really doesn't make any sense for me.
Thanks in advance.