Can you limit the amount of information displayed from an SD card on a webpage?

Hello everyone, I'm fairly new to Arduino. I'm working with a sketch that records voltage values on an SD card and then displays the values from the SD card on to a web page as data entries. Every 15 minutes a new data entry will be recorded on the SD card and displayed on the webpage. Here's the code:

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6 };
IPAddress ip(192, 168, 1, 177); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

File webFile;
File myFile;
void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for debugging
    
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
   pinMode(10, OUTPUT);
   
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("index.htm", FILE_WRITE);
  
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to index.htm...");
    myFile.println("Voltage, Current, Power");
	// close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening index.htm");
  }
  
  // re-open the file for reading:
  myFile = SD.open("index.htm");
  if (myFile) {
    Serial.println("index.htm:");
    
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    	Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
  	// if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
  
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    webFile = SD.open("index.htm");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
    
    // make a string for assembling the data to log:
 

  // read three sensors and append to the string:
int voltageSensor = analogRead(A0);
int currentSensor = analogRead(A1);

float voltage = voltageSensor * (5.0 / 1023.0);
float current = currentSensor * (150.0 / 1023.0);
float power = voltage * current;


  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("index.htm", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.print("<HTML>");
    dataFile.print("<BODY>");
    dataFile.print("<P>");
    dataFile.print(voltage); 
    dataFile.print(",");
    dataFile.print(current);
    dataFile.print(",");
    dataFile.print(power);
    dataFile.println("</P></BODY></HTML>");
    dataFile.close();
    // print to the serial port too:
    
    
  }  
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening index.htm");
  } 
  delay(900000);
}

The problem I'm having is that the code will display an infinite amount of data entries on the webpage and I just want it to display the most recent 360 data entries. You can probably imagine after a long period of time there will be a really long list of data entries and so that's why I would like to be able to display only a certain amount of the most recent data entries.

And so my question is: is it possible to limit the amount of data entries taken from an SD card in which are displayed on a webpage? and if so then how?

Thanks,

And so my question is: is it possible to limit the amount of data entries taken from an SD card in which are displayed on a webpage? and if so then how?

Of course it is. Open the file. Read the whole thing. Count the records. Close the file. Open it again. Read and discard the first n records. Then, read and send the rest.

Of course, if you used fixed length records, you could tell how many records were in the file when you opened it, and jump directly to the nth record, and start reading and sending from the start of that record.

  delay(900000);

That's a pretty unresponsive server you are running there. Imagine if google asked you to wait 15 minutes when you tried to execute a search request.

By the way, there is nothing magic about the name index.htm. It has implied meaning when used in a client/server context that is not matched by what your server returns from the file of that name on the SD card. You could use a better name to store the data.

I'm building a data logger as well, I don't know about that topic yet.
but put the arduino to sleep instead of delay could be and upgrade.
I'll keep reading the thread.