程序代写代做代考 Steps for Importing CSV files to Neo4j

Steps for Importing CSV files to Neo4j
Dear students,
For Section 3, we explained the steps needed for importing the CSV files to a Neo4j graph in the discussion session. Just in case, if you missed it we will repeat the steps here:
 
1 – Creating nodes: 
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM “file:///HW5-Dataset/business.csv” AS row
CREATE (:Business {business_id: row.business_id, name: row.name, review_count: row.review_count, state: row.state, city: row.city, categories: row.categories, attributes_RestaurantsDelivery: row.attributes_RestaurantsDelivery});

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM “file:///HW5-Dataset/review.csv” AS row
MERGE (:Review {review_id: row.review_id, stars: row.stars})

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM “file:///HW5-Dataset/review.csv” AS row
MERGE (:User {user_id: row.user_id})
 
2 – Creating indexes to expedite adding relationships in the next step:
CREATE INDEX ON :Business(business_id);
CREATE INDEX ON :Review(review_id);
CREATE INDEX ON :Review(user_id);
CREATE INDEX ON :Review(business_id);
CREATE INDEX ON :User(user_id);
CREATE INDEX ON :Business(states);

3 – Adding relationships
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM “file:///HW5-Dataset/review.csv” AS row
MATCH (business:Business {business_id: row.business_id})
MATCH (review:Review {review_id: row.review_id})
MERGE (business)-[:HAS]->(review);

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM “file:///HW5-Dataset/review.csv” AS row
MATCH (user:User {user_id: row.user_id})
MATCH (review:Review {review_id: row.review_id})
MERGE (user)-[:REVIEWED]->(review);
 
Note that these steps are only one possible way to import the CSV files and you don’t need to follow it if you already imported the files, and you might use other queries and/or create another schema for the graph based on your needs.
 
In case you hit errors related to Text column, you can use the CSV file without Text column that is available here: https://www.dropbox.com/s/ercfz5yju9vqdky/review_without_text_column.csv?dl=0

/docProps/thumbnail.jpeg