Concatenating files in order

Mahmood Naderan nt_mahmood at yahoo.com
Tue May 23 16:16:56 EDT 2017


>Yup.  Make a list of all the file names, write a key function that 
>extracts the numbery bits, sort the list based on that key function, and 
>go to town.
>
>Alternatively, when you create the files in the first place, make sure 
>to use more leading zeros than you could possibly need. 
>xxx_chunk_000001 sorts less than xxx_chunk_000010.




So, if I write

import glob;
for f in glob.glob('*chunk*'):
      print(f)

it will print in order. Is that really sorted or it is not guaranteed?

Regards,
Mahmood



More information about the Python-list mailing list