leeper/csvy

Write YAML/JSON metadata in a separate function?

andrewheiss opened this issue · 1 comments

Currently it's possible to write CSVY metadata data to a separate file instead of at the top of the CSV file with write_csvy(..., metadata = "path/to/metadata.yaml"). This must be done in conjunction with writing a CSV file, though—write_csvy() doesn't work unless you specify an output file for the CSV. It might be helpful to have a function like write_metadata() that only writes the metadata without writing the CSV too.

For instance, I've run into an issue where I want to use readr::write_csv() to write a CSV because of its NA handling options, speed, tidyverseability, etc., but I also want to include CSVY YAML metadata as a separate file to distribute along with it. My current solution is to write two CSV files—one with write_csv() and one with write_csvy(..., metadata = "blah.yaml")—and then delete the CSV created with write_csvy(). But that's super roundabout and inefficient.

Totally doable - we'll just move the metadata-writing code from write_csvy() into a separate function and export it.