Create a file format (csv,json,etc) when save/update a Post

There are a number of action hooks for Post Status Transitions. They each receive the $post object as an argument. You could use these to trigger a function that writes your file to disk using fopen.

Edit: if you’re writing CSV, PHP has a function specifically for that: fputcsv (fopen still required)

error code: 523