Skip to content

Commit b0d7037

Browse files
committed
fixed table export to csv with empty cells (#2028)
1 parent 7afd8c3 commit b0d7037

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ct/ct_misc_utils.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ std::string CtCSV::table_to_csv(const CtStringTable& table)
105105
{
106106
std::string ret_str;
107107
for (const auto& row : table) {
108-
for (const auto& cell : row) {
109-
ret_str += fmt::format("\"{}\"", str::replace(cell, std::string{"\""}, std::string{"\\\""}));
108+
const size_t numCols = row.size();
109+
for (size_t i = 0u; i < numCols; ++i) {
110+
ret_str += fmt::format("\"{}\"", str::replace(row.at(i), std::string{"\""}, std::string{"\\\""}));
110111

111-
if (cell != row.back()) ret_str += ",";
112+
if (i < (numCols - 1u)) ret_str += ",";
112113
}
113114
ret_str += "\n";
114115
}

0 commit comments

Comments
 (0)