Combine files from different nodes

I’m trying to combine a series of text files. The problem is that I’m getting the files from different nodes. My script looks something like this:

A = Node(CreateFilesA(out_names=['file1','file2']), name="A")
B = Node(CreateFilesB(out_names=['file3']), name="B")

The idea is to pass file1 (from node A) and file 3 (from node B) to another node:

def fun(*files):
    list_of_files = files
    return list_of_files
grabfiles = Node(Function(function='fun', input_names=['files'], output_names= "list_of_files"), name = "grabfiles")

The problem is that I can only connect grabfiles once, so the following code fails

	    (A, "file1", grabfiles, "files"),\
            (B, "file3", grabfiles, "files")]) #grabfiles already connected

so I’m wondering whether there is a workaround to this problem.

Hi @mri,

you can always create an additional node and use Function Interface to wrap a function that merge two lists.

Or, if this example is somewhat real, you could expand the inputs of your function to account for the different node sources as different input parameters. (i.e., instead of “files”, your function would take “files_from_A” and “files_from_B”)