cancel
Showing results for 
Search instead for 
Did you mean: 

Importing multiple files?

mbandor
Graph Voyager

I'm looking at a project where there are multiple text files (each being a report that needs to be parsed). There is a standard naming convention for the files (xxx-report#.txt). Is there an easy way to read through the list of files and then one-by-one do an import of the data?

3 REPLIES 3

depends what your parsing entails.

you can do

UNWIND range(1,100) as id
LOAD CSV FROM "file://xxx-report"+id+".txt") as row FIELTERMINATOR '\n'
....

if you configure newlines as field terminators each of your rows is a single element array.

I like the solution, but the ID numbers are not sequential. They are case numbers in the file name. I do like the possible idea of having a file with the list of filenames in it, then reading it to start iterating through the individual file contents.

I may end up researching some basic Python script to wrap around it as another way to look at the task.

Yep, if you have a file or api or something with the case numbers you can load them them from there and then iterate over that list.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.