Advertisement
Queen4

Parsing logs v0.5

Dec 13th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <stdlib.h>
  5.                        
  6.  
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11. string line;
  12. float *t0 = NULL;
  13. int tount = 0;  
  14. int k;
  15.  
  16.     ifstream logs_("C:/Users/Dmitry/Desktop/Zhuikov project/logGLO.txt");
  17.     ofstream tout("outLOGTime.txt");
  18.     ofstream pout("outLOGPot.txt");
  19.     if (logs_.is_open())
  20.     {
  21.         while (!logs_.eof())
  22.         {
  23.            k = 0;
  24.             logs_ >> line;
  25.            
  26.                 /*if(line.substr(0,6) == "$GPGGA")
  27.                 {  
  28.                
  29.                     if (t0)
  30.                     {  
  31.                         tout << atof(line.substr(7,10).c_str()) - *t0 << endl;
  32.                     }
  33.                     else
  34.                     {
  35.                         t0 = new float;
  36.  
  37.                         *t0 = atof(line.substr(7,10).c_str());
  38.                     }
  39.                     tount++;
  40.                 }*/
  41.                 /*else*/ if (line.substr(0,6) == "$GPGSV")
  42.                 {
  43.                     for(int N = 7; N <= 19; N+=4)
  44.                     {
  45.  
  46.                         for (size_t i = 0; i < line.size(); i++)
  47.                         if (line.at(i) == ',') k++;
  48.                         if(k == N)
  49.  
  50.                         {
  51.                             pout << atof(line.substr(0,2).c_str()) << endl;
  52.                         }
  53.                     }
  54.                 }
  55.            
  56.         logs_.close();
  57.         tout << "K-vo Zna4eniy -- " << tount << endl;
  58.         }
  59.     }
  60.     else
  61.         cout<<"File is not open"<<'\n';
  62.     tout.close();
  63.     pout.close();
  64.  
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement