# deleteFireRows.py
# Purpose: Remove all but MDAIP fire records
# Usage: No arguments required.  Input file hard-coded.
# Output: Modified text file *_edited.txt in the scratch directory.
import os

inputFileName = "C:/gispy/data/ch19/fireData.txt"
outputFileName = "C:/gispy/scratch/fireData_edited.txt"
if os.path.isfile( inputFileName ):
    infile = open( inputFileName, 'r' )   # Create read file object.  
    outfile = open( outputFileName, 'w' ) # Create write file object.
    line = infile.readline()              # Read header line.
    outfile.write(line)                   # Write header line.
    for line in infile:
        lineList = line.split('\t')       # Split on tab since some
                                          # field values contain spaces.
        if lineList[2] == "MDAIP":
            outfile.write(line)           # Write row in output file.
    infile.close()
    outfile.close()
    print("{0} created.".format(outputFileName))
