def mygen(reader):
    for row in reader:
        yield row[0], row[1], row[2], row[3], row[4]
reader = csv.reader("""foo,bar,baz,spam,ham,eggs
42,81,13,97,73,100
""".
    splitlines())
writes = csv.writer(sys.stdout, delimiter=' ', quoting=csv.QUOTE_ALL)
writes.writerows(mygen(reader))
How to write in .csv file from a generator in python