Concatenating files in order
woooee at gmail.com
woooee at gmail.com
Tue May 23 16:38:59 EDT 2017
It is very straight forward; split on "_", create a new list of lists that contains a sublist of [file ending as an integer, file name], and sort
fnames=["XXX_chunk_0",
"XXX_chunk_10",
"XXX_chunk_1",
"XXX_chunk_20",
"XXX_chunk_2"]
sorted_list=[[int(name.split("_")[-1]), name] for name in fnames]
print "before sorting", sorted_list
sorted_list.sort()
print "after sorting ", sorted_list
More information about the Python-list
mailing list