First let me say thanks to everyone who has been responding to my posts and providing valuable insight. I have been trying to add rep whenever possible, and appreciate your help.
My assignment was to write a python code which takes data from an infile, then has the user specify a column out of the infile, and then the program writes only the information from that column to an outfile. Thanks to help from you guys, I've also been able to include a portion of the code which will skip over blank lines instead of crashing. I'd like to optimize/change the code with your suggestions. I feel that I've probably included too many operations and am being redundant in places. Here is my code, with comments which try to convey my level of understanding. Please add suggestions and point out where my comments are fallacious.
def columns(infile, outfile):
f = open(infile,'r')
o = open(outfile,'w')
col = int(raw_input('Please select a column (starting at 0) from you in file, %s:' % (infile)))
temp = [] #Store an empty list
for line in f:
if not line.strip(): #If empty line, strip the new line character and remaining space
continue
else:
line = line.split() #Split lines so that they can be operated on via list operations
temp.append(line[col]) #Write the user-specified column into the empty list, "temp
o.write('\n'.join(temp))
print "See %s" % (outfile)
f.close()
o.close()