ENH: a function to export to csv format