Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Importing multiple files?

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?


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.