Skip to content

tonicebrian/csv_iterator

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 

csv_iterator

A flexible iterator library written in C++ for traversing CSV files

Usage:

Just copy the the files under the folder include in your include files. In your code include the csv_iterator.hpp header and using the boost tuples declare an iterator reading from an istream. The contructor without arguments is a synomim for the end of the stream.

The minimal example would be:

#include <fstream>
#include <boost/tuple/tuple.hpp>
#include <csv_iterator.hpp>

using namespace boost::tuples;
typedef tuple<int,std::string,double> record;

void myFunc(const record& value){
    // Your code here
}

int main(int argc, const char *argv[])
{
    // Example of csv_iterator usage
    std::ifstream in("myCsvFile.csv");
    csv::iterator<record> it(in);

    // Use the iterator in your algorithms.
    std::for_each(it, csv::iterator<record>(), myFunc);

    return 0;
}

Testing

In order to ensure that the libraries work for your platform type make test

Libraries:

sudo apt-get install cmake libboost-dev liboost-iostreams-dev

About

A fully typed iterator for walking CSV files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published