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); } }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
And here is an example of the output.
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.
Fig 2: A sample of the CSV file.