In order to import this data into Neo4j and create a graph, we first have to import the user's data (the nodes) and then create the relationships between them from the edgelist file. After copying both files into the import folder of your Neo4j graph, you can use the following two queries to import the data:
- Run the following to import nodes:
LOAD CSV WITH HEADERS FROM "file:///data_ch8.csv" AS row
CREATE (u:User) SET u=row
- Run the following to import the relationships:
LOAD CSV FROM "file:///data_ch8.edgelist" AS row
FIELDTERMINATOR " "
MATCH (u:User {user_id: row[0]})
MATCH (v:User {user_id: row[1]})
CREATE (u)-[:FOLLOWS]->(v)
Once the data is imported into Neo4j, as we did with the CSV file in the previous section, we are going to characterize this data.