- Joined
- 4/21/11
- Messages
- 878
- Points
- 73
So. I have a CSV Parser that I built. It works very well. The way it currently works is that I have the parser in a header file "CSV_Parser". So my .cpp code would look like this:
This all works great. I am running Eclipse in Linux (Xubuntu to be precise). In the header file the .csv is opened as follows:
What I would like is for the user to be able to change the file that the parser is opening through the main .cpp file. In other words, is there a way to create some variable, say "FileName" and do the following:
And then the .h would now say:
Obviously this does not work. Ultimately the goal is for me to open 4 .csvs at one time so I can do numerical operations on them.
Code:
#include <iostream>
#include <eigen3/Eigen/Dense>
#include "CSV_Parser.h"
using namespace std;
using Eigen;
int main()
{
CSV matrixA; //CSV is the parser class name
matrixA.extract(); //runs the parser
cout << matrixA.CSV_Matrix; //CSV_Matrix is the public name of a Eigen matrix which receives the stripped Matrix
}
This all works great. I am running Eclipse in Linux (Xubuntu to be precise). In the header file the .csv is opened as follows:
Code:
ifstream infile;
infile.open("/home/mross/Desktop/Matrix.csv");
What I would like is for the user to be able to change the file that the parser is opening through the main .cpp file. In other words, is there a way to create some variable, say "FileName" and do the following:
Code:
CSV firstMat;
string MatrixA = "/home/mross/Desktop/Matrix1.csv";
firstMat.extract(MatrixA);
CSV secondMat;
string MatrixB = "/home/mross/Desktop/Matrix2.csv";
secondMat.extract(MatrixB);
And then the .h would now say:
Code:
void extract(string FileName)
...
ifstream infile;
infile.open(FileName);
Obviously this does not work. Ultimately the goal is for me to open 4 .csvs at one time so I can do numerical operations on them.