Removing last row from appending CSV file
<p>I would like to remove the last row appended to a CSV file (sort of like 'undo' last appended row).  So far I have an interface that takes a user-generated raw_input and performs a command.  For instance, 'a' adds the row to the CSV file, 'r' rejects the row from the CSV file.  I would like 'u' to remove the last row added to the CSV file.  My code looks like this</p>

<pre><code>for i in range(0,len(out['bestObjID']),1):
    j = raw_input('\n Add (a) or Reject (r)?: ')
    if j=='ADD' or j=='add' or j=='a' or j=='A':
        c = csv.writer(open('NLS1_candidates.csv','a+'))
        c.writerow(out[i])
        print(' Writing object to candidate list...')
        i += 1
    elif j=='REJECT' or j=='reject' or j=='r' or j=='R':
        print(' Object rejected...')
        i += 1
    elif j=='UNDO' or j=='undo' or j=='u' or j=='U':
        i -= 1
    elif j=='?' or j=='h' or j=='help' or j=='HELP' or j=='H':
        print('    \n Press (a) to add object to candidate list')
        print('     Press (r) to add to reject object')
        print('     Press (?) or (h) for help')
        print('     Press (q) to Quit')
    elif j=='q' or j=='Q' or j=='QUIT' or j=='quit':
        print('\n Quitting...')
        break
    else:
        print('    \n Press (a) to add object to candidate list')
        print('     Press (r) to add to reject object')
        print('     Press (?) or (h) for help')
        print('     Press (q) to Quit')
</code></pre>

<p>How would I go about adding 'undo' functionality to my CSV file?</p>

<p>Edit: I've failed to mention that when I add a row to the CSV file, <code>out[i]</code> is a row read from another CSV file.  If that helps at all.</p>