Domanda

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))
È stato utile?

Soluzione

def passfiles(alist):
    values = []
    for filenames in alist:
        values.append(filetocsv(filenames))
    return values
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top