Skip to content

My csv files can have changing number of columns #119

Description

@heisenbuug

Hey. I was exploring this repo.
So I want to read a .csv file and store its content into an arma::mat.

I have 3 files with 5, 15, 25 columns.
I don't want to do this

  io::CSVReader<5> doc5("data/electricity-usage5.csv");
  io::CSVReader<5> doc15("data/electricity-usage15.csv");
  io::CSVReader<5> doc25("data/electricity-usage25.csv");

I want something like

arma::Col<unsigned> colu = {5, 15, 25};
for(int i = 0; i <3; i++)
{
    const unsigned a = col_sizes(i);
    io::CSVReader<a> doc("data/electricity-usage.csv");
}

But this is giving me an error.

Also is it compulsory to initialize with a number of columns? What if I don't know how many columns does the .csv file has.
Also is there a way to read data column-wise?
And if I have 25 columns, how will I read the whole row at once?

Thank you for the help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions