# Purpose: Read the input file and write the records where
#          the species is LP to another file.
#          Example of deleting rows.
# Usage: No arguments required.  Input file hard-coded.
# Output: Modified text file RDUout3.txt in the scratch directory.
inputFile = "C:/gispy/data/ch19/RDUforest.txt"
outputFile = "C:/gispy/scratch/RDUout3.txt"

if os.path.exists(inputFile):
    inf = open(inputFile, 'r')
    outf = open(outputFile, 'w')

    header = inf.readline()
    outf.write(header)
    for line in inf:
        splitLine = line.split("\t")
        species =splitLine[2]
        if species == "LP":        
            outf.write(line)

    inf.close()
    outf.close()

    print("{0} created.".format(outputFile))
