import os,argparse parser=argparse.ArgumentParser(description="read the deviation file, multiply the distortions and write a new distortion file") parser.add_argument("filename",help='name of the distortion file',type=str) parser.add_argument("factor",help='the factor to multiply the distortions with',type=int) args=parser.parse_args() infile=open(args.filename,'r') outfile=open(args.filename.replace('.txt','_'+str(args.factor)+'.txt'),'w') counter=0 numbers=[0.,0.,0.,0.,0.] for line in infile: if counter==0: outfile.write(line) counter+=1 continue words=line.split() newline='' for i in range(5): if i < 3 : numbers[i]=float(words[i])*args.factor else: numbers[i]=float(words[i]) newline+=str(numbers[i])+' ' newline+='\n' outfile.write(newline) infile.close() outfile.close()