sorting out data and putting it in an array

hi.

Im importing some numbers daily via wifi to arduino, which i would like to put in an array and compare each value to the mean value of all the numbers in the array.

the imported data is in text format.

like "

Kl 00 - 01 6.53 öre/kWh Kl 01 - 02 6.48 öre/kWh "

i first need to sort this data and convert it to a number...
i would like to store the data in an array, so i can call on 6,53 for example via price[0] and 6,48 price [1] and so on...

Any ideas?

What have you tried so far? How are you fetching this data? When you retrieve it, do you store it in a 'String' object or char array?

Based on those answers, you will need to search your string to find the portion you want. You can then use atof() to convert that string into a floating point number of put it into your array

i = 0;
while (client.available()) {                                         
    char c = client.read();                                            

    response[i] = c;
    i++;
    Serial.write(c);                                                  
    }


    j = 0;
    while (j<i)
    {
        if (response[j] == '<' && response[j+1] == 't' && response[j+2] == 'd' && response[j+3] == '>')
        {
          svar[0] = response[j+4];
          svar[1] = response[j+5];
          svar[2] = response[j+6];
          svar[3] = response[j+7];
          svar[4] = response[j+8];
          break;
        }
         j++;
    };
  
  pris[0] = atof(svar);
  Serial.printf("Measurement:  %f\n", pris[0]);

but there must be an easier way of doing it i presume?

and im fetching the data from a website... via:

  void httpRequest() {                                               
    client.stop();                                                    
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
     client.println("GET https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXX HTTP/1.1");      
    client.println("Host: www.thingspeak.com");
    client.println("User-Agent: ArduinoWiFi/1.1");
    client.println("Connection: close");
    client.println();
    }
    else {
    Serial.println("connection failed");
  }

Which board are you using for this?

bulanspatel:
but there must be an easier way of doing it i presume?

you could use strstr to find the opening td tags and atof to test what comes next, if it's a float, copy it to your array.

for example...

void setup()
{

  Serial.begin(115200 );
  while(!Serial);

  char response[] =
    "<tbody>"
    "<tr>"
    "<td>Kl 00 -  01</td>"
    "<td>6.53 öre/kWh</td>"
    "</tr>"
    "<tr>"
    "<td>Kl 01 -  02</td>"
    "<td>6.48 öre/kWh</td>"
    "</tr>"
    "<tr>";

  char tag[] = "<td>";
  uint8_t offset = strlen( tag );
  char* ptr = strstr( response, tag ); // locate the first tag

  while( ptr)
  {
    ptr += offset; // advance the pointer to the first character after the tag
    float val = atof( ptr );
    if( val !=0 ) Serial.println( val ); // pris[ index ] = val; test / copy etc
    ptr = strstr( ptr, tag ); // find next tag 
  }
}

void loop() {}

Thanks for the helt, sorted it out!