Problem with ifstream, iftream gives same number

Hello Guys,
I am currently trying to read out a csv file with 16 columns and 10000 rows. The most values are between 100 and 1000. Values above are not of interest for me. From time to time there happen to be values of: 4294967295. I am reading out the data with the help of an ifstream. As the readout method reaches this value all following read out values are set to the last value before 4294967295. Example Code:

<ifstream* MeasurementFile=new ifstram(someName);
double dActualValue;
int iActualRows=0;
int iMaximalRows=10000;
int iNumberOfColumns=16;
while (iActualRows<iMaximalRows)&&(!MeasurementFile->eof())){
for (int i=0;i<iNumberOfColumns;i++){
*MeasurementFile>>dActualValue;
cout<<dActualValue<<" ";
}
cout<<endl;
iActualRows++;
}>

If a csv has two rows whith these example values:
1 2 3 4 5 6 4294967295 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

The output becomes:
1 2 3 4 5 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

For all upcoming rows, the value i get from the ifstream is 6. It seems i am stuck in some kind of loop. I dont know how to prevent this problem and cant find a solution with help of the search. Can you please give me some kind of help or a hint how i can solve this?

Best regards Jarmikala

the code doesn't even compile, paste the actual code that you are using.


> ifstream* MeasurementFile=new ifstram(someName);
http://www.cplusplus.com/forum/general/138037/
Thanks for the response. I am actually using a program with more than 2000 lines, which is to big for a post or to explain the problem. Therefore i just just wrote an example to show what i am doing. I am not really sure what i should post you right now. If i dont post the whole program u wont be able to compile it. Maybe i post the method which causes the problem and explain what the code does. I am measuring something with 16 channels. For every measured event i get a new column in the file. The method i am posting reads a file and checks the values for the desired channels. If the values are in the given range they are summed up. The method then gives me the average of a certain channel to a global array (dADCAmplifier[i][j]).


//load amplifier measurement from file get start channel to end channel (Starts from 0, goes to 15; File has all Channels) and store to array or load amplifier data from file (Option 1)
void loadAmplifierMeasurement(string sAmplifierFileName,int iStartChannel, int iEndChannel,double dMaxEventAmplifier,int iMinEventHeight,double dMaxEventHeight,int iOffsetOption,int iOption){
//File needs data of all channels
//sAmplifierName File to read Measurement
//iStartChannel first channel to be read out
//iEndChannel last channel to be read out
//dMaxEventAmplifier maximal number of read out events
//iMinEventHeight minimal event height to be needed, not implemented
//dMaxEventHeight maximal event height to be needed
//iOffsetOption 0 to use offset
//iOption:
//0=>load Amplifier Measurement (averaged Value) for each channel for two pulse heights, calculate amplfication factor, Store to file
//1=>load Amplfier Factor from File
//8=>1 with cout
//9=>0 wih cout
if ((iOption==9)||(iOption==8)){cout<<"++"<<"loadAmplifierMeasurement starting"<<endl;}
if ((iOption!=0)&&(iOption!=1)&&(iOption!=8)&&(iOption!=9)){cout<<"wrong Option Parameter in loadAmplifierMeasurement. Standard is 0"<<endl;}
long double dActEventCharge=0;
int iActFile=0;
int iRealEventBuffer=0;
int iErrorBuffer=0;
if ((iOption==0)||(iOption==9)){
double dADCAmplifierBuffer[4][25];
setStringToChar(cAmplifierMeasurement,sAmplifierFileName,0);
ifstream* AmplifierMeasurementFile=loadIfstreamFile(cAmplifierMeasurement,0);
ofstream* AmplifierValuesFile=loadOfstreamFile(cAmplifierValues,0);
//set Amplifier to 0
for (Int_t i=0; i<iNofADC; i++){
for (Int_t j=0; j<iNofADCCh; j++){
if ((j>=iStartChannel)&&(j<=iEndChannel)){
dADCAmplifier[i][j]=0;
}
if (iOption==9){cout<<"dADCAmplifier["<<i<<"]["<<j<<"]"<<": "<<dADCAmplifier[i][j]<<"; ";}
}
}
if (iOption==9){cout<<endl;}
//Get Data
while ((iActFile<dMaxEventAmplifier)&&(!AmplifierMeasurementFile->eof())){
if (iOption==9){cout<<"load Event Number ["<<iActFile+1<<"]"<<endl;}
for (Int_t l=0; l<iNofADC; l++){
for (Int_t m=0; m<iNofADCCh; m++){
if (!AmplifierMeasurementFile->eof()){
//only channels between start and end channel used, error buffer if event out of range (min-max), only max implemented
*AmplifierMeasurementFile>>dActEventCharge;
cout<<dActEventCharge<<" ";
if ((m>=iStartChannel)&&(m<=iEndChannel)) {
dADCAmplifierBuffer[l][m]=dActEventCharge;
//if the baseline shall be considered
if (iOffsetOption==0){
if (dAmplifierOffset[l][m]<0){dAmplifierOffset[l][m]=0;}
dADCAmplifierBuffer[l][m]-=dAmplifierOffset[l][m];
}
if (iOption==9){cout<<"ADCAmplifierBuffer["<<l<<"]["<<m<<"]"<<": "<<dADCAmplifierBuffer[l][m]<<"; ";}
}
if ((dActEventCharge>=dMaxEventHeight)){
iErrorBuffer+=1;
}
}
}
}

if (iOption==9){cout<<endl;}
//if no error write data to dADCAmplifier
for (Int_t l=0; l<iNofADC; l++){
for (Int_t m=0; m<iNofADCCh; m++){
if ((m>=iStartChannel)&&(m<=iEndChannel)&&(dADCAmplifierBuffer[l][m]>=iMinEventHeight)&&(dADCAmplifierBuffer[l][m]<=dMaxEventHeight)&&(iErrorBuffer==0)) {
dADCAmplifier[l][m]+=(dADCAmplifierBuffer[l][m]);
iRealEventBuffer+=1;
}
if (iOption==9){cout<<"ADCAmplifier["<<l<<"]["<<m<<"]"<<": "<<dADCAmplifier[l][m]<<"; ";}

}
}
iErrorBuffer=0;
if (iOption==9){cout<<endl;}
iActFile++;
}
//Divide channels through number of events
if (iOption==9){cout<<"Divide channels through number of events"<<endl;}
for (Int_t i=0; i<iNofADC; i++){
for (Int_t j=0; j<iNofADCCh; j++){
if ((j>=iStartChannel)&&(j<=iEndChannel)) {
dADCAmplifier[i][j]=dADCAmplifier[i][j]/iRealEventBuffer;
dADCAmplifier[i][j]=int(dADCAmplifier[i][j]);
}
if (iOption==9){cout<<"dADCAmplifier["<<i<<"]["<<j<<"]"<<": "<<dADCAmplifier[i][j]<<"; ";}
}
}
if (iOption==9){cout<<endl;}
closeIfstreamFile(AmplifierMeasurementFile,0);
closeOfstreamFile(AmplifierValuesFile,0);
}
if ((iOption==1)||(iOption==8)){
ifstream* AmplifierMeasurementValuesFile=loadIfstreamFile(cAmplifierMeasurementValuesShort,0);
if (iOption==8){cout<<"load AmplifierValues from File ["<<cAmplifierValues<<"]"<<endl;}
for (Int_t i=0; i<iNofADC; i++){
for (Int_t j=0; j<iNofADCCh; j++){
if (!AmplifierMeasurementValuesFile->eof()){
*AmplifierMeasurementValuesFile>>iActEventCharge;
if ((j>=iStartChannel)&&(j<=iEndChannel)&&(iActEventCharge>iMinEventHeight)&&(iActEventCharge<dMaxEventHeight)) {
dADCAmplifier[i][j]=iActEventCharge;
}
if (iOption==8){cout<<"dADCAmplifier["<<i<<"]["<<j<<"]"<<": "<<dADCAmplifier[i][j]<<"; ";}
}
}
}

if (iOption==8){cout<<endl;}
closeIfstreamFile(AmplifierMeasurementValuesFile,0);
}
if ((iOption==9)||(iOption==8)){cout<<"--"<<"loadAmplifierMeasurement ended"<<endl;}
}
Thank for trying to help me. I was actually able to solve it. The value has been to big. By changing the data type to long double i could make the method work.
Topic archived. No new replies allowed.