DRY up some more of the CSV generation code.