I have a set of files in a directory. So I created a function that apply some processing to all the files in the directory:
def fancy_function(directory, regex):
for set the path of the directory:
with open the file names and walk over them:
preprocessing1 = [....]
preprocessing2 = [ remove some punctuation from preprocessing1]
return preprocessing2
Then I do the following:
list_of_lists = fancy_function(a_directory, a_regex)
print list_of_lists
>>>['processed string']
It just return one list and the directory actually have 5 files, then when I do the following:
def fancy_function(directory, regex):
do preprocessing...
preprocessing1 = [....]
preprocessing2 = [ remove some punctuation from preprocessing1]
print preprocessing2
print fancy_function(a_directory, a_regex)
It returns the 5 preprocessed files that I want like this:
['file one']
['file two']
['file three']
['file four']
['file five']
Why is this happening and how can I obtain the 5 files in a list?. I would like to save them In one list in order to make a nother processing but now for each list in the main list, something like this:
main_list =[['file one'], ['file two'], ['file three'], ['file four'], ['file five']]