Cleanup upload.py

* Fix most of the pep8 violations
* DebugPrint => print (DebugPrint was not defined)
* Misc renaming
* Ensure csv file handle is properly disposed of
* General cleanup