Sayth Renshaw wrote, on January 03, 2017 5:36 PM > > So can I call the generator twice and receive the same file > twice in 2 for loops? > > Once to get the files name and the second to process? > > for file in rootobs: > base = os.path.basename(file.name) > write_to = os.path.join("output", > os.path.splitext(base)[0] + ".csv") > with open(write_to, 'w', newline='') as csvf: > for file in rootobs: > # create and write csv > > Cheers > > Sayth
I don't see why not, if you let the first one run to completion and then do it again a second time. Assuming your generator doesn't somehow delete or modify the file specifications as it yields them. It would be helpful to see the code for rootobs, if you have it. D. -- https://mail.python.org/mailman/listinfo/python-list