kraken-assessment/src/csv/write-csv.cc
Bruno BELANYI bd072e1025 kraken: csv: fix comma separation logic
Unfortunately, `std::ostream_iterator` puts its separator *after* every
element, not *in-between* each element.
2022-03-12 11:07:20 +01:00

21 lines
422 B
C++

#include "write-csv.hh"
#include <algorithm>
#include <iostream>
#include <iterator>
namespace kraken::csv {
void write_csv(std::ostream& output, csv_type const& csv) {
for (const auto& line : csv) {
bool first = true;
for (const auto& atom : line) {
output << (first ? "" : ",") << atom;
first = false;
};
output << '\n';
}
}
} // namespace kraken::csv