Failing to read a CSV file

 
Hi guys.

I'm trying to read in a csv file with 2 rows and 8 columns and I keep failing.  I'm able to open the file, however I cannot yet access the content of the file. Here is my code.
//+------------------------------------------------------------------+
//|                                                     Read CSV.mq5 |
//|                                        Gamuchirai Zororo Ndawana |
//|                          https://www.mql5.com/en/gamuchiraindawa |
//+------------------------------------------------------------------+
#property copyright "Gamuchirai Zororo Ndawana"
#property link      "https://www.mql5.com/en/gamuchiraindawa"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- Read in the file
   string file_name = "sp500_treasury_yields_scale.csv";

//--- Try open the file
   int result = FileOpen(file_name,FILE_READ|FILE_CSV,",");

//--- Check the result
   if(result != INVALID_HANDLE)
     {
      Print("Opened the file");
      //--- Store the values of the file
      float mean_values[8];
      float variance[8];

      for(int i = 0; i < 10; i++)
        {
         //--- Print the content of the file
         Print("Trying to read float: ",FileReadFloat(result));
         Print("Trying to read string: ",FileReadString(result));
        }

      //---Close the file
      FileClose(result);
     }

  }
//+------------------------------------------------------------------+

And here is an example of the output.

Failing to parse a CSV file

Fig 1: Failing to parse a CSV file.


Here is a sample of the content of the CSV file I'm trying to parse. Each column has a title, so I thought maybe I should use FileReadString to handle the column title and ReadFloat for the real values, but I'm failing so far.

The CSV file

Fig 2: A sample of the CSV file.

 
void OnStart()
  {
//--- Read in the file
   string file_name = "EURUSD.PERIOD_H1.csv";

//--- Try open the file
   int result = FileOpen(file_name,FILE_READ|FILE_CSV|FILE_ANSI,","); //Strings of ANSI type (one byte symbols). 

//--- Check the result
   if(result != INVALID_HANDLE)
     {
      Print("Opened the file");
      //--- Store the values of the file
      float mean_values[8];
      float variance[8];
      
      int counter = 0;
      string value = "";
      while(!FileIsEnding(result) && !IsStopped()) //read the entire csv file to the end 
       {
         if (counter > 10) //if you aim to read 10 values set a break point after 10 elements have been read
           break; //stop the reading progress
         
         value = FileReadString(result);
         Print("Trying to read string: ",value);
            
         if(FileIsLineEnding(result))
           { 
             Print("row++");
           }
         
         counter++;
       }
       
      //---Close the file
      FileClose(result);
     }
  }
 
Omega J Msigwa #:
Thank you Omega, it's working perfectly <3