Concatenating files in order

Mahmood Naderan nt_mahmood at yahoo.com
Thu May 25 16:37:14 EDT 2017


Hi guys,


Cameron, thanks for the points. In fact the file name contains multiple '_' characters. So, I appreciate what you recommended.





  filenames = {}

  for name in glob.glob('*chunk_*'):

    left, right = name.rsplit('_', 1)

    if left.endswith('chunk') and right.isdigit():

      filenames[int(right)] = filename

  sorted_filenames = [ filenames[k] for k in sorted(filenames.keys()) ]




It seems that 'filename' should be 'right'.  



Regards,

Mahmood



More information about the Python-list mailing list