PIA-Group/BioSPPy

Walktree not working

mc-m opened this issue · 3 comments

mc-m commented

I can't seem to obtain any resut from the walktree function.

I'm doing this: filename = walktree(top= '../../data/Trials', spec=r'\.XML$')

and the function acts like if I had no file in that directory whatsoever (see images for better understanding).

Thank you

cenas

sem titulo

Hi @mc-m
It seems that in your call to walktree you have two extra `
It should just be r'\.txt$'

mc-m commented

Yes, you were right, thank you!

However, I'm getting another error. Not sure if it's about this fuction or not.

github

Also, @capcarr, how does the function return the file names when there's more than one? Is it a list?

Thank you,

Hi @mc-m

The function returns a generator function, which are useful in iterative loops.

You can obtain a list with all the elements by doing:
files = list(walktree(...))

Regarding your error, it seems that you are feeding the variable filename to another function, which expects a string. You probably wanted to pass f.