Python: Using oswalk in first function to find files, pass name, then trying to open in second function
Question: I am trying to use two functions to find files and process them, the output of
which, ultimately, will be sent to a SQlite3 database. I have the second part
working when NOT a function, but for this, need to enter the name of each file
to be processed. I want it automated, hence the first function with oswalk.
However, when I add the first function, which finds the files and returns them
to the second function, something is going wrong. In the code posted, I just
want to test that the files are being passed and can be opened and read one at
a time.

Notes about what is happening and pointers to the output (which will be pasted
below the code) are hashed out in the code below.

    
    
    import os
    import fnmatch
    
    def findFiles (path, filter):
        Files = []
        for root, dirs, files in os.walk(path):
            for file in fnmatch.filter(files, filter):
               Files.append(os.path.join(root, file))
        return Files
    
    def fastq2SQlite(Files):
        for file in Files:
            print file    ## At this point, I have a list of files.  See "A" below.  
    
            with open(file, 'r'):  ##If this block is then added, it's evident that the files shown 
                                   ##in "A" are not being recognized as files.  Output is "A" 
                                   ##transposed, each line a letter of a file name.
                for line in file:
                    print line
    

Output "A"  
C:/Users/Documents/JKC10/test.txt  
C:/Users/Documents/JKC10/test2.txt  
C:/Users/Documents/JKC10/test3.txt  
None

I have even unsuccessfully tried to get the files to be read by modifying them
so that their names become (example): 'C:/Users/Documents/JKC10/test_out.txt'

by adding a block that looks like:

    
    
    def fastq2SQlite(Files):
        for file in Files:
            f = "'" + file + "'"
    


Answer: 
    import os
    import fnmatch
    
    def findFiles (path, filter):
        Files = []
        for root, dirs, files in os.walk(path):
            for file in fnmatch.filter(files, filter):
               Files.append(os.path.join(root, file))
        return Files
    
    def fastq2SQlite(Files):
        for file_ in Files:
            print file_    
    
            with open(file_, 'r') as dummy_file:
    
                for line in dummy_file:
                    print line
    

You should also avoid using the keywords like `file`, etc. as variable names,
It overrides the original object and can cause some serious issues, Just a
good programming practice.

