bell_pepper
bell_pepper

Reputation: 187

Neo4j Adding multiple CSV in one query

I have a folder of csv files like this - "1232422.csv"

headers:

"ID","Name","ScreenName","location","Friends","Followers","Verified","Description","URL","Created_At"

there are 1500 files, with the filename having a "follows" relation with the rows of the csv file : (filename)-[follows]-(csv_row)

What is the best way to upload all of the data to my neo4j Graph?

Upvotes: 2

Views: 165

Answers (1)

cybersam
cybersam

Reputation: 67019

Assuming that the import config settings are correct, you can pass the list of filenames (e.g., ["1232422", "1232423", ...]) as a filenames parameter to this query:

UNWIND $filenames AS filename
LOAD CSV WITH HEADERS FROM "file:///"+filename+".csv" AS data
CREATE (f:File {filename:filename})-[:FOLLOWS]->(r:Row)
SET r.csv_row = data

Upvotes: 0

Related Questions