Recently I worked on an eLance side project after hours to retrieve e-mails that included CSV files from a GMail account and was pretty happy with the outcome, so I wanted to share it here.  The script prompts for configuration options (continuing if a config file already exists), installs the getmail and ripmime packages if they don’t exist, creates the database and table schema if it doesn’t exist, strips special characters that might cause insertion issues, and finally dumps the info into a MySQL database.  Based on the primary key, it also allows for updates of the existing data (ad hoc update) if a file is placed in the report directory or resent to the e-mail address specified in the configuration.

Certain parts of it could definitely be improved (e.g. not to dump the passwords into the file plain-text, prompt for CSV column to database column mapping, etc), but overall I’m happy with it for the time I was allotted, which was 5 hours (even though I spent more than that on it).

The script is available here for anyone interested.  I still don’t think it’s good enough to put on GitHub or anything, so maybe I’ll just wait for my 3 line implementation of SkyNet in C# or something.  :P