I'm reading in data from a csv file that has some columns ending before others, i.e.:
0.01 0.02 0.01
0.02 0.02
And I'm trying to figure out how to catch these empty locations and what to do with them. My current code looks like this:
#include <iostream>
#include <fstream>
#include <sstream>
int main(){
//Code that reads in the data, determines number of rows & columns
//Set up array the size of all the cells (including empty):
double *ary = new double[cols*rows]; //Array of pointers
double var;
std::string s;
int i = 0, j = 0;
while(getline(data,line))
{
std::istringstream iss(line); //Each line in a string
while(iss >> var) //Send cell data to placeholder
{
ary[i*cols+j] = var;
j+=1;
}
i+=1;
}
How can I determine if the cell is empty? I want to convert these to "NaN" somehow. Thank you!