Let’s say you have a file with 276 lines, and you only need lines from 96 to 276. You can use this code:

#!/usr/bin/python
#command line: python smCreate.py 200nm.50.700.out.dat 200nm.50.700.out.dat
import sys
import shutil
#for arg in sys.argv:    #shows input arguments
#    print arg
print 'Input file:'+ sys.argv[1]
print 'Output file:'+ sys.argv[2]

shutil.copy(sys.argv[1],sys.argv[2])# copied content to the new file

inputFile = open(sys.argv[1], "r+")
outputFile = open(sys.argv[2], "w")

outputFile.writelines(inputFile.readlines()[96:276])
inputFile.close()
outputFile.close()
print 'created sm file with scattering matrix'

Last modified: 2017-07-21