Skip to content

C++/Boost-based library for reading and writing CSV files

License

Notifications You must be signed in to change notification settings

planed-es/csvpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csvpp

C++/Boost-based library for reading and writing CSV files

Examples

Reading a CSV file

#include <csv/document.hpp>
#include <iostream>

int main()
{
  Csv::Document my_document;
  
  my_document.load_from_file("input.csv");
  for (const auto& row : my_document)
  {
    std::cout << "Row content: "
              << row.get("id") << ": "
              << row.get("value") << std::endl;
  }
  return 0;
}

Writing a CSV file

#include <csv/writer.hpp>
#include <ofstream>

int main()
{
  std::ofstream file;
  file.open("output.csv");

  Csv::Writer writer(file, ';');
  Csv::Row header, row;
  
  header.push_back("id");
  header.push_back("value");
  writer.insert(header);
  row.push_back("1");
  row.push_back("that's the value column content");
  writer.insert(row);
  file.close();
  return 0;
}

About

C++/Boost-based library for reading and writing CSV files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published