Generating csv files from an api