opening an excel file and writing to it in python
Question: How do I open an existing excel file, write to it, and save it as the same
filename. None of the previous data should be lost and the new data should be
saved.

The pseudocode would be as follows:

    
    
    open excel file
    write data to last row
    save excel file
    


Answer: If you are willing to use csv format (has obvious limitations) you can use
Python's built in [CSV library](http://docs.python.org/2/library/csv.html).

Here is a short reader example:

    
    
     >>> import csv
     >>> with open('eggs.csv', 'rb') as csvfile:
     ...     spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
     ...     for row in spamreader:
     ...         print ', '.join(row)
     Spam, Spam, Spam, Spam, Spam, Baked Beans
     Spam, Lovely Spam, Wonderful Spam
    

Writer example:

    
    
    import csv
    with open('eggs.csv', 'a') as csvfile:
        spamwriter = csv.writer(csvfile, delimiter=',',
                                quotechar='|', quoting=csv.QUOTE_MINIMAL)
        spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
        spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
    

Keep in mind with csv, you can only modify spreadsheet data, no fancy graphs
or anything.

