Skip to content

Is this library possible to create and edit a csv file? #153

Closed Answered by d99kris
Michaelzhouisnotwhite asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Michaelzhouisnotwhite - yes that should work. Here is another example:

int main()
{
  rapidcsv::Document doc("");

  doc.InsertColumn(0, std::vector<std::string>(), "A");
  doc.InsertColumn(1, std::vector<std::string>(), "B");
  doc.InsertColumn(2, std::vector<std::string>(), "C");

  doc.InsertRow(0, std::vector<std::string>({ "a1", "b1", "c1" }));
  doc.InsertRow(1, std::vector<std::string>({ "a2", "b2", "c2" }));
  doc.InsertRow(2, std::vector<std::string>({ "a3", "b3", "c3" }));

  std::ostringstream sstream;
  doc.Save(sstream);
  std::cout << sstream.str();
}

Resulting in:

A,B,C
a1,b1,c1
a2,b2,c2
a3,b3,c3

Searching the tests/ directory for tests containing generate new document

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Michaelzhouisnotwhite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants