I am going through every line of code and copying and pasting it into a new file from a previous file because I am adding in a new column of data.
When I go through every column, the last row has null characters or some wierd characters that are interfering with how my data looks. How can I remove it?
Here's my code:
Code:
//while loop to extract data from .txt file and calculate pixel degrees
while(getline(datain, line1))
{
istringstream datstream(line1, istringstream::in);
datstream >> dum1[0] >> dum1[1] >> dum1[2] >> dum1[3] >> dum1[4] >> dum1[5] ;
datastore[i][0] = strtod(dum1[0].c_str(), &pEnd); //lat
datastore[i][1] = strtod(dum1[1].c_str(), &pEnd); //long
latpix[i] = (laurentides.lat-datastore[i][0])/(laurentides.x_pixsize);
lonpix[i] = (datastore[i][1]- laurentides.lon)/(laurentides.y_pixsize );
//offset here calculates the number of pixels that the data occupies in the actual binary file and points to it
offset = latpix[i]*laurentides.numsamples+lonpix[i];
//here were getting the size of the data in memory
offset = offset*sizeof(float);
// cout<<"reading file at "<< offset <<endl;
is.seekg (offset, ios::beg);
is.read ((char *) &value[i], sizeof(double));
//THIS IS WHERE I RUN INTO TROUBLE I THINK......BUT DONT KNOW HOW TOFIX
asciiwrite << dum1[0] << " " << dum1[1] << " " << dum1[2] << " " << dum1[3] << " " << dum1[4] << " " << dum1[5] << " " << value[i] << endl;
if( i == 9)
break;
i++;
}
OUTPUT:
Code:
46.710014 -71.259471 44.489597 -1.485428 -0.059414 6.298206\ -26.1162
46.710042 -71.259701 44.635906 -1.841427 -0.475201 3.920475\ -31.8444
46.710211 -71.259656 44.435902 -1.663170 -0.178196 8.078243\ -23.5934
46.710182 -71.259423 44.253120 -1.307129 0.297077 9.149914\ -16.6559
46.710153 -71.259189 44.764111 -1.723507 -0.118870 7.547733\ -21.2177
46.710124 -71.258954 44.675690 -1.783405 -0.237782 6.836391\ -22.4409
46.710095 -71.258722 44.358482 -1.248703 0.356777 11.476242\ -20.1352
46.710066 -71.258488 44.750996 -1.427460 -0.059471 8.624260\ -29.1568
46.710037 -71.258255 44.537296 -1.427830 -0.178478 4.164490\ -31.9196
46.710008 -71.258021 44.579990 -1.606709 -0.297535 4.165527} -29.0219
I want to remove "\" this and other weird characters that may pop up. this was a test run of a few lines. I don't know how though. I tried using a space width limiter but that didn't work.