0

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))
Kuzen
  • 950
  • 3
  • 10
  • 15
  • to person who was trying to help with generators, my responce was - This is my learning code doing things in basic stages, my ultimate goal is to take values from a csv based on row data, put them somewhere else, (another csv maybe), add headers to each column, then recombine all the data back together. Should I be learning generators for this? – Kuzen May 11 '14 at 16:27

1 Answers1

0
def passfiles(alist):
    values = []
    for filenames in alist:
        values.append(filetocsv(filenames))
    return values
Liteye
  • 2,761
  • 1
  • 16
  • 16