Commit 76700357 authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

codes to extract the avr and rms of one .dat file

parent 9278c532
void avr(){
std::ifstream infile("000/000_000.dat");
if(infile.is_open()){
cout<<"The data file is opened..."<<std::endl;
std::string line;
while(!infile.eof()){
std::getline(infile,line);
if(line.rfind("#",0)!=0){
continue;
}
cout<<"original line : " <<line<<std::endl;
std::string newline = " ";
for(int i=0;i<line.length();i++){
if(line[i]!=':'){
newline=newline+line[i];
}
else{
newline=newline+line[i]+" ";
}
}
cout<<"The new line with spaces " <<newline<<std::endl;
std::stringstream s;
s<<newline;
cout<<"The line is stored in the stringstream object..."<<std::endl;
string temp;
double num;
while(!s.eof()){
s>>temp;
if(std::stringstream(temp)>>num){
cout<<num<<std::endl;
}
temp = " ";
}
}
}
else{
cout<<"Error..."<<std::endl;
}
cout<<"done..."<<std::endl;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment