Prettify csv output algorithm.