file - In Python, how do I iterate over one iterator and then another? -


I want to repeat two different iterators, something like this:

  file1 = a / Second; open for item in second (file 1, file2) ('file1', 'r') file2 = open ('file2', 'r'): print item   

I expected to print all the rows of file 1, then all the lines of file2

I want something normal, as it can not be an iterator file, it's just an example I know I can do this:

  for item [ File1] + [file2]:   

But it reads both the files in memory, which I prefer to avoid from you.

Usage: chain for chain in import from itertools (File 1, File 2): Pass

The module also offers a similar feature: fileinput.input ['File1', 'file2']): Pass

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -