There's more...

This script can be further improved. Here's a recommendation:

  • Create more robust CSV writers with additional feature sets and options. The idea here is that you could supply data of different types and have a method to handle them equivalently.