d99kris/rapidcsv

SetRowName didn't throw out of range when set row didn't exist

lushengguo opened this issue · 1 comments

int main() {
  std::istringstream stream("a,b,c");
  rapidcsv::Document doc(stream, rapidcsv::LabelParams(0, 0));
  doc.SetRowName(0, "d");
  std::ostringstream oss;
  doc.Save(oss);
  std::cout << oss.str() << std::endl;
}

result:
a,b,c
d

if SetRowName didn't throw error, expected result shoud be:
a,b,c
d,,

Project has no example/test code tells how to dump data to a csv file, I misused API SetRowName like list code and fixed the error after reading the impl of SetRowName and noticed that there is an API called InsertRow >.< , SetCell throws exception when cell didn't exist, then why SetRowName didn't throw exception when row didn't exist?

Hi @lushengguo - this is actually the expected behavior for rapidcsv. It allows building/creating new documents by setting row/column labels outside current range - see #57 for more details. Other Set-functions in rapidcsv behave similarly. I will proceed to close this issue.