Question

I am trying to pass a list through a function, but I only get results from first value in list, how do I get the rest?

filetype = ('HDR','ILD','STL','TLR')

f= open ("C:\Console2\word\\testfile.test",'rt')
reader = csv.reader(f)

def filetocsv(ftype):
    typerow = [row for row in reader if row[0] == ftype]
    f.seek(0)
    return (typerow)

def passfiles(alist):
    for filenames in alist:
        values = filetocsv(filenames)
        return (values)

print (passfiles(filetype))
Was it helpful?

Solution

def passfiles(alist):
    values = []
    for filenames in alist:
        values.append(filetocsv(filenames))
    return values
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top