Reading CSV files

 

Hi guys, in need of some tips for reading .csv files. Below is an example. Say I want to read in I4 as a string and assign it to a variable. If I did this in Python I'd just have each line as an array and would be able to access I4 as:

myString = myCSVFile[4][8] #Python code

Is there a similar way I can do it in MQL4? I know I have to open the file first like below, but how do I go from there? I've been able to write to a csv file, but reading it seems to be harder.

int filehandle = FileOpen("myCSVFile.csv",FILE_READ|FILE_WRITE|FILE_CSV);

csv file


Thanks in advance.

 
Dohan Rivas:

Hi guys, in need of some tips for reading .csv files. Below is an example. Say I want to read in I4 as a string and assign it to a variable. If I did this in Python I'd just have each line as an array and would be able to access I4 as:

Is there a similar way I can do it in MQL4? I know I have to open the file first like below, but how do I go from there? I've been able to write to a csv file, but reading it seems to be harder.


Thanks in advance.

Read the documentation to start, code what you want. Once it's done make it a library "python like" so next time you will need something similar, you will be able to use "myString = myCSVFile[4][8]"
Documentation on MQL5: File Functions
Documentation on MQL5: File Functions
  • www.mql5.com
For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means cannot be outside the file sandbox. the common folder for all the terminals installed on a computer - usually located in the directory C:\Documents and Settings\All Users\Application...