read and write data as csv format