Write csv to the given directory.