Coder Social home page Coder Social logo

Comments (1)

d99kris avatar d99kris commented on June 4, 2024

Hi @vagrawal-aptina - yes, this should be supported by rapidcsv.

Let's say the CSV file content is:

# Line 0 with no CSV data
# Line 1 with no CSV data
# Line 2 with no CSV data
Date,Open,High,Low,Close,Volume,Adj Close
2017-02-24,64.529999,64.800003,64.139999,64.620003,21705200,64.620003
2017-02-23,64.419998,64.730003,64.190002,64.620003,20235200,64.620003
2017-02-22,64.330002,64.389999,64.050003,64.360001,19259700,64.360001
2017-02-21,64.610001,64.949997,64.449997,64.489998,19384900,64.489998
2017-02-17,64.470001,64.690002,64.300003,64.620003,21234600,64.620003
2017-02-16,64.739998,65.239998,64.440002,64.519997,20524700,64.519997

Then we can tell rapidcsv that the column headers (Date,Open,High,Low,...) are at line 3 using the LabelParams argument, like this:

int main()
{
  rapidcsv::Document doc("examples/rowoffset.csv", rapidcsv::LabelParams(3, -1));
  std::cout << "First data row date: " << doc.GetColumn<std::string>("Date").at(0) << "\n";
}

The expected output of this program will be:

First data row date: 2017-02-24

Hope this illustrates how the row offset works. Feel free to re-open the issue if you have follow-up questions!

from rapidcsv.

Related Issues (20)

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.