Screwing Up looping in Generator

Sayth Renshaw flebber.crue at gmail.com
Tue Jan 3 20:35:59 EST 2017


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


More information about the Python-list mailing list