Code Monkey home page Code Monkey logo

csvparser's Introduction

CSVparser

CSVparser intends to be a simple C++ parser for the CSV file format.

What is a CSV file ?

CSV is a common, relatively simple file format that is widely supported by consumer, business, and scientific applications. Among its most common uses is moving tabular data between programs that natively operate on incompatible (often proprietary and/or undocumented) formats. This works because so many programs support some variation of CSV at least as an alternative import/export format.

Compilation

g++ CSVparser.cpp -std=c++0x

Usage

The following example shows how to make a simple usage of CSVparser.
Assuming a common CSV file :

Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar
#include <iostream>
#include "CSVparser.hpp"

int main(int argc, char **argv)
{
	try
    {
        csv::Parser file = csv::Parser("files/readme.csv");

        std::cout << file[0][0] << std::endl; // display : 1997
        std::cout << file[0] << std::endl; // display : 1997 | Ford | E350

        std::cout << file[1]["Model"] << std::endl; // display : Cougar

        std::cout << file.rowCount() << std::endl; // display : 2
        std::cout << file.columnCount() << std::endl; // display : 3

        std::cout << file.getHeaderElement(2) << std::endl; // display : Model
    }
    catch (csv::Error &e)
    {
        std::cerr << e.what() << std::endl;
    }
  	return 0;
}

csvparser's People

Contributors

rsylvian avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.