Refactor csv

Uses the python csv library to generate the csv rows
Uses a cleaner way to generate the data for the csv columns
Uses iterators and generators to save memory during the table generation