I have a data of nearly 1000 elements and want to read some of the columns into an array. the first two lines are the headers and I'd like to skip them. I also need to calculate the differences between some numbers two consecutive columns and display the result on a different column.
Data looks something like this
444,,,
x-coordinates,y-coordinates,a,b
3.00,-4.00,2.00,6.00
0.67,-3.88,0.00,0.00
I want to have an output similar to
3.00 -4.00 6.00
0.67 -3.88 0.00
and so on
This is what I've tried so far.
After opening the file successfully and declaring variables:
getline(inFile, line, ',');//obtain number of rows
getline(inFile, line, '\n');//skip first two lines
getline(inFile, line, '\n');
while (inFile.good())//
{
getline(inFile, temp, ',');//read first column seperated by ','
x[i] = stod(temp);
getline(inFile, temp, ',');//read second column seperated by ','
y[i] = stod(temp);
getline(inFile, dummy, ',');
getline(inFile, temp, ',');//read third column seperated by ','
b[i] = stod(temp);
I get this as output
2.12242e-3146.95333e-3102.12239e-3146.95333e-310 7656.67 2.12235e-3147.90868e-3152.12239e-314 0 7656.67 1.39612e-3096.95323e-3102.12239e-314 0 7656.67 4.29837e-3226.95333e-3102.12239e-3143.95253e-323 7656.67 4.34778e-3227.90868e-3152.1224e-314 0 7656.67 6.95325e-3106.95319e-3102.1224e-314 0 7656.67 4.94066e-3246.95333e-3102.1224e-3142.12399e-314 7656.67 07.90868e-3152.1224e-314 0 7656.67 6.95333e-3106.95323e-3102.12241e-314 0 7656.67 2.12242e-3146.95333e-3102.12241e-3146.95313e-310 7656.67 2.12235e-3147.90868e-3152.12241e-314 0 7656.67 1.39612e-3096.95321e-3102.12241e-314 0 7656.67 3.6462e-3216.95333e-3102.12241e-314-3.58185e+263 7656.67 3.67585e-3217.94207e-3152.12242e-314 0 7656.67 6.95326e-3106.95319e-3102.12242e-314 0 7656.67 4.94066e-3246.95333e-3102.12244e-3146.95313e-310 7656.67 07.94207e-3152.12244e-314 0 7656.67 6.95333e-3106.95323e-3102.12245e-314 0 7656.67 2.12242e-3146.95333e-3102.12245e-3142.52962e-320 7656.67 2.12235e-3147.90868e-3152.12246e-314 0 7656.67 1.39612e-3096.95323e-3102.12239e-314 0 7656.67 5.92879e-3226.95333e-3102.12239e-3142.12399e-314 7656.67 5.92879e-3227.90868e-3152.12239e-314 0 7656.67 6.95326e-3106.95323e-3102.12239e-314 0 7656.67 4.94066e-3246.95333e-3102.12239e-3146.07701e-322 7656.67 07.90868e-3152.12239e-314