A csv reader/writer in C++ using standard objects.
 
 
 
Go to file
Natalie Adams 39cf9ae84e adding code 2021-10-22 15:30:52 -05:00
include adding code 2021-10-22 15:30:52 -05:00
src adding code 2021-10-22 15:30:52 -05:00
LICENSE Initial commit 2021-05-17 02:49:01 +00:00
Makefile adding code 2021-10-22 15:30:52 -05:00
README.md dump from hg repo 2021-05-16 21:51:08 -05:00
csv2.py adding code 2021-10-22 15:30:52 -05:00
csvtest.py adding code 2021-10-22 15:30:52 -05:00
main.cpp adding code 2021-10-22 15:30:52 -05:00
sampledata.csv adding code 2021-10-22 15:30:52 -05:00
tests.cpp adding code 2021-10-22 15:30:52 -05:00

README.md

csvpp

A csv reader/writer in C++ using standard objects.

Features:

  • Read from a file or string
  • Support for optionally enclosed elements (using " as the enclosure )
  • Easy to iterate through the rows
  • Associative arrays which allow accessing by the column name!
  • Optionally - RowReader has two optional constructor parameter, first is a bool which determines if it should use headers and second is the newline delimeter. The default is true (use headers) and \n for newline
  • Automatically adjusts for \n or \r\n

Here is a very simple example using a string:

#include <iostream>
#include <sstream>
#include "csvpp.h"

using namespace std;
using namespace csvpp;

int main()
{

        RowReader tmp;
        //RowWriter rw;
        stringstream ss;
        ss << "field1,field2,field3\r\n123,234,345\r\n999,000,111\r\n";
        ss >> tmp;
        rowiterator it;
        while(ss << tmp)
        {
                for(it = tmp.begin(); it != tmp.end(); it++)
                        cout << it->first << " => " << it->second << endl;
                cout << endl;
        }
        //cout << rw;
        return 0;

}