Rewrite export using csv module