Add csv output generation

This adds a draft for csv output generation.