csv
csv copied to clipboard
Option to append to file when writing
This is same use case as #16 except for writing to a file. An option to have the writer append to an existing file would be very helpful. Even better might be adding a csv::Writer
constructor which takes a std::ostream
.
I think you need to modify the header file: /include/writer.hpp
。
Below is what I've add to ctor:
#include <sys/stat.h>
// in the ctor:
// check if the file already exits
struct stat buf;
if (stat(file_name.c_str(), &buf) != -1)
{
header_written_ = true;
file_stream.open(file_name, std::ios::app);
} else
{
file_stream.open(file_name);
}