You can use the file I/O library to write CSV files. Pretty straight forward.
If you're using a PLC like a WAGO 750-88x you've got about a meg to Play with. The 750-880 has an SD RAM slot so you can store up to 8G. Be warned, however, that if you're planning to do a lot of this, SD RAM has a limited number of writes, about 1M if I remember correctly.
If you're using the soft PLC the number of writes is not an issue.