Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.

Option to append to file when writing #17

Open
jwillikers opened this issue Mar 10, 2020 · 1 comment
Open

Option to append to file when writing #17

jwillikers opened this issue Mar 10, 2020 · 1 comment

Comments

@jwillikers
Copy link
Contributor

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.

@williamlfang
Copy link

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);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants