Skip to content

Commit

Permalink
fixed table export to csv with empty cells (#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuspen committed Feb 4, 2025
1 parent 7afd8c3 commit b0d7037
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ct/ct_misc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ std::string CtCSV::table_to_csv(const CtStringTable& table)
{
std::string ret_str;
for (const auto& row : table) {
for (const auto& cell : row) {
ret_str += fmt::format("\"{}\"", str::replace(cell, std::string{"\""}, std::string{"\\\""}));
const size_t numCols = row.size();
for (size_t i = 0u; i < numCols; ++i) {
ret_str += fmt::format("\"{}\"", str::replace(row.at(i), std::string{"\""}, std::string{"\\\""}));

if (cell != row.back()) ret_str += ",";
if (i < (numCols - 1u)) ret_str += ",";
}
ret_str += "\n";
}
Expand Down

0 comments on commit b0d7037

Please sign in to comment.