# deleteFireColumn.py
# Purpose: Remove the last column.
# Usage: No arguments required.  Input file hard-coded.
# Output: Modified text file *_columnRemoved.txt in the scratch directory.
inputFileName = "C:/gispy/data/ch19/fireData.txt"
outputFileName = "C:/gispy/scratch/fireData_columnRemoved.txt"
try:
    infile = open( inputFileName, 'r' )     
    outfile = open( outputFileName, 'w' ) 
    for line in infile:
        #MODIFY the input line
        lineList = line.split('\t')  
        lineList.pop()               # Remove the last attribute.
        line = '\t'.join(lineList)   # Convert back to tab delimited string.
        line = line + '\n'           # Add a carriage return.
        
        #WRITE the modified line in the output file.
        outfile.write(line)
        
    infile.close()
    outfile.close()
    print("{0} created.".format(outputFileName))
except IOError:
    print("{0} does not exist.".format(inputFileName))
