Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. maximum value and the minimum value of csv file
Forum Updated to NodeBB v4.3 + New Features

maximum value and the minimum value of csv file

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 789 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    genli
    wrote on last edited by
    #1

    i have a csv file i been able to read it with qt but I would like to take the maximum value and the minimum value and put them in a variable
    how can i do it please

    jsulmJ 1 Reply Last reply
    0
    • G genli

      i have a csv file i been able to read it with qt but I would like to take the maximum value and the minimum value and put them in a variable
      how can i do it please

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @genli This is a very simple programming exercise. What did you try so far? You simply need to iterate over the values and in each iteration check whether the value is smaller than current smallest value or bigger than current biggest value.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      3
      • jsulmJ jsulm

        @genli This is a very simple programming exercise. What did you try so far? You simply need to iterate over the values and in each iteration check whether the value is smaller than current smallest value or bigger than current biggest value.

        G Offline
        G Offline
        genli
        wrote on last edited by
        #3

        @jsulm i try this but it shows me all the value of the column :
        qreal x = parts.at(0).toDouble(&ok);
        listefinale<< x ;
        std::sort(listefinale.begin(), listefinale.end());
        Imin= listefinale.first();
        Imax= listefinale.last();
        qDebug() << Imax;
        qDebug() << Imin;

        1 Reply Last reply
        0
        • G Offline
          G Offline
          genli
          wrote on last edited by
          #4

          Imin = listefinale[0];
          Imax = listefinale[0];
          for (int i=1; i<listefinale.size(); i++)
          {
          if (listefinale[i] < Imin)
          Imin = listefinale[i];
          if (listefinale[i] > Imax)
          Imax = listefinale[i];
          }
          but it did work

          J.HilkJ 1 Reply Last reply
          0
          • G genli

            Imin = listefinale[0];
            Imax = listefinale[0];
            for (int i=1; i<listefinale.size(); i++)
            {
            if (listefinale[i] < Imin)
            Imin = listefinale[i];
            if (listefinale[i] > Imax)
            Imax = listefinale[i];
            }
            but it did work

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @genli it should are you sure you know the content of your listefinale?

            anyway, since we're actually a c++ language:

                QVector<int> listefinale( 100000,0 );
            
                // create random numbers
                std::generate( listefinale.begin(), listefinale.end(), rand );
            
                int Imin = *std::min_element(listefinale.begin(), listefinale.end());
                int Imax = *std::max_element(listefinale.begin(), listefinale.end());
                qDebug()  << Imin << Imax;
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            G 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @genli it should are you sure you know the content of your listefinale?

              anyway, since we're actually a c++ language:

                  QVector<int> listefinale( 100000,0 );
              
                  // create random numbers
                  std::generate( listefinale.begin(), listefinale.end(), rand );
              
                  int Imin = *std::min_element(listefinale.begin(), listefinale.end());
                  int Imax = *std::max_element(listefinale.begin(), listefinale.end());
                  qDebug()  << Imin << Imax;
              
              G Offline
              G Offline
              genli
              wrote on last edited by
              #6

              @J-Hilk i don't know why he shows me all the value of the column

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved