7
#Append the contents of one file to another
8
def appendFile(sourceFile,targetFile):
10
fileSrc = open(sourceFile,"rb")
11
fileTarget = open(targetFile,"ab")
13
#Extremely inefficient!!
14
byte = fileSrc.read(1)
16
fileTarget.write(byte)
26
#Name of file that we will dump our results to
27
OUTPUT_POSFILE="output.pos"
29
#Remove any old files from previous runs
30
if os.path.isfile(OUTPUT_POSFILE) :
31
os.remove(OUTPUT_POSFILE)
34
# do nothing if we have no arguments
38
#Loop over all our inputs, then for .pos files,
39
# create one big file with all data merged
41
print "given file :" + i
45
if appendFile(i,OUTPUT_POSFILE):
46
return 1; #Output to file failed, for some reason
48
print "appended file to " + OUTPUT_POSFILE
51
#Filename did not end in .pos, lets ignore it.
52
print "File :" + i + " does not appear to be a pos file";
57
if __name__ == "__main__":