How do I access multiple files from a folder in anduril?

27 views
Skip to first unread message

lolmo

unread,
Aug 23, 2013, 2:39:06 AM8/23/13
to andur...@googlegroups.com
Hey,
so I'm trying to run an anduril script over certain files in a folder, whilst also accessing the file names in later components. How would one go about doing that?

Riku Louhimo

unread,
Aug 23, 2013, 3:16:03 AM8/23/13
to andur...@googlegroups.com
Hi,

Use the Folder2Array component. With Folder2Array, you give your folder as an INPUT instance and get an array. You can then use iterArray to go thru all the files in a loop. In Folder2Array you can also use regexp to define which files you get from the input folder e.g., if you have case and control samples in the same folder, you can easily create two different arrays (assuming the names of files reflect this somehow)

Hope this helps,
Riku

Ville Rantanen

unread,
Aug 23, 2013, 3:45:36 AM8/23/13
to andur...@googlegroups.com
I can present a piece of code explaining the action


my_folder=INPUT(path="path_to_folder")
my_array=Folder2Array(my_folder,  filePattern=".*extension")

foo={}
for rec: std.iterArray(my_array.array) {
    std.echo("This is the unique key:", rec.key)
    std.echo("This is the path to the file:", rec.file)
    // Using the files as an input for components:
    foo[rec.key] = CSVJoin( my_array.array[rec.key] )
}

you can access a file directly if you know it's key. 


The file list can be converted to a CSV with  Array2CSV for manipulation within a component.. 
Reply all
Reply to author
Forward
0 new messages