Skip to content

Instantly share code, notes, and snippets.

@kbighorse
Created March 30, 2017 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbighorse/c9546c467c51239167b224a1f95ff549 to your computer and use it in GitHub Desktop.
Save kbighorse/c9546c467c51239167b224a1f95ff549 to your computer and use it in GitHub Desktop.
// Create resources
//USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:avon_test_tables_Resources.csv" AS row
CREATE (:Resource {nameOrTitle: row.NameOrTitle, topic: row.Topic, type: row.Type, summary: row.Summary, keywords: row.Keywords, URL: row.URL, year: row.Year})
// Create topics
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///data.csv" AS row
CREATE (:Topic {title: row.Topic, id: row.TopicID})
// Create types
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:avon_test_tables_Types.csv" AS row
CREATE (:Type {type: row.Type})
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:orders.csv" AS row
MATCH (order:Order {orderID: row.OrderID})
MATCH (product:Product {productID: row.ProductID})
MERGE (order)-[pu:PRODUCT]->(product)
ON CREATE SET pu.unitPrice = toFloat(row.UnitPrice), pu.quantity = toFloat(row.Quantity);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:orders.csv" AS row
MATCH (order:Order {orderID: row.OrderID})
MATCH (employee:Employee {employeeID: row.EmployeeID})
MERGE (employee)-[:SOLD]->(order);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:orders.csv" AS row
MATCH (order:Order {orderID: row.OrderID})
MATCH (customer:Customer {customerID: row.CustomerID})
MERGE (customer)-[:PURCHASED]->(order);
match (r:Resource)
unwind split(r.topic, ',') as topic_id
match (t:Topic)
where t.id = trim(topic_id)
create (r)-[:HAS_TOPIC]->(t)
match (r:Resource)
unwind split(r.topic, ',') as topic_id
match (t:Topic)
where t.id = trim(topic_id)
create (r)-[:HAS_TOPIC]->(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment