I have a list of part files (that is many parts of single file).
I want to append all parts into a single file to make a full file.
I used this code:
import os l = ["home/baskar/1.part","home/baskar/2.part","home/baskar/3.part"] source_file ="/home/baskar/source.file" re_size = 0 buffer = 10*1024 #10 KiB's for x in range(len(l)): target_size = os.path.getsize(l[x]) part = open(l[x],"r") while 1: output = part.read(buffer) re_size = re_size + len(output) F = open(source_file,"ab") F.write(output) F.close() if re_size == target_size: break else:print "Appending file",l[x]
This code works perfectly ,But it takes much long time for appending file, even small file like 5mb file takes 3 min to complete.
Is there is any way to append file or is there is any wrong with my code ?
if anyone know please tell me.
Thanks in advance
Edited 7 Years Ago by baskar007: n/a