Export to CSV

Here is the rest of the code so that export to CSV works. Works through
all my testing.