reading data from an sd card

I am trying to read data from sd card and want to calculate the average of the particular data I required.
Given below is my code.

/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

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

File myFile, myFile1;
int CS_pin=4;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
   pinMode(CS_pin,OUTPUT);

  Serial.print("Initializing SD card...");

  if (!SD.begin(CS_pin)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");


 double dtemp[4488], sum=0, val=0, avg;
int i, count=0, j=0, counter, do_nothing;
  // re-open the file for reading:
  myFile = SD.open("edited3.txt");
  if (myFile) {
    Serial.println("edited3.txt:");

   
for (i = 0;((myFile.available()) && (i <1122)); i++) {

if(myFile.read()=='A')
{ 
  count=count + 1;
  dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=0.43+dtemp[i];
  Serial.println(val);
  sum=sum+val;
  Serial.println(sum);
}
else if(myFile.read()=='B')
{ 
  count=count + 1;
  dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=1.32+dtemp[i];
  Serial.println(val);
  sum=sum+val;

  Serial.println(sum);
}
else  if(myFile.read()=='C')
{ 
  count=count + 1;
  dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=5.24+dtemp[i];
  Serial.println(val);
  sum=sum+val;
  Serial.println(sum);
}
else if(myFile.read()=='D')
{ 
  count=count + 1;
  dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=11.79+dtemp[i];
  Serial.println(val);
  sum=sum+val;
  Serial.println(sum);
}
else if(myFile.read()=='E')
{ 
  count=count + 1;
  dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=22.28+dtemp[i];
  Serial.println(val);
  sum=sum+val;
  Serial.println(sum);
}
else if(myFile.read()=='F')
{ 
  count=count + 1;

   dtemp[i]=myFile.parseFloat();
  Serial.println(dtemp[i]);
  val=29.7+dtemp[i];
  Serial.println(val);
  sum=sum+val;
  Serial.println(sum); 
//  }
  
}
else
{
  do_nothing=1;
}
}
//counter= count-j;
Serial.print(F("Sum:"));
Serial.println(sum);
Serial.print(F("Count:"));
Serial.println(count);

avg=sum/count;
Serial.print(F("Average:"));
Serial.println(avg);

    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening edited3.txt");
  }

}



void loop() {
  // nothing happens after setup
}

Below I have attached the text file which I am trying to read from the sd card. But the problem is that all the values that I require for average calculation won’t get read. Below is my serial monitor output:

Initializing SD card…initialization done.
edited3.txt:
3.16
8.40
8.40
3.07
8.31
16.71
3.35
8.59
25.30
3.26
8.50
33.80
3.35
8.59
42.39
-1.73
10.06
52.45
-1.04
4.20
56.65
1.67
6.91
63.56
2.27
7.51
71.07
2.53
7.77
78.84
2.89
8.13
86.97
3.07
8.31
95.28
3.35
8.59
103.87
Sum:103.87
Count:13
Average:7.99

I have 30 readings from which only 13 are being read. HELP!

edited3.txt (1.09 KB)

 double dtemp[4488], sum=0, val=0, avg;

On which Arduino? 4488 doubles uses 17952 bytes of SRAM, of the 2048 bytes that most Arduinos have.

for (i = 0;((myFile.available()) && (i <1122)); i++)

(Do) (you) (have) (a) (parentheses) (fetish) (?)

for (i = 0;((myFile.available()) && (i <1122)); i++)
{
  if(myFile.read()=='A')
  {
  }
  else if(myFile.read()=='B')
  {
  }
  else  if(myFile.read()=='C')
  {
  }
  else  if(myFile.read()=='D')
  {
  }
  else  if(myFile.read()=='E')
  {
  }
  else  if(myFile.read()=='F')
  {
  }
}

Read a character. If it is not an A, read another one. See if it’s a B. If not, read another one, and see if it’s a C.

Do you not see that that is nonsense? Read ONE character. Compare it to A, B, C, etc.

You WILL need save the character in a variable.