Download MetaTrader 5
To add comments, please log in or register
Do you know C++? MQL5 has much in common with it. Just try it yourself!
Luis 2015.12.15 18:45 

Im kinda shock, maybe anyone of you could help me.

I dont understand why this returns me the columns changed order. I have an CSV with 2columms full of data. And this returns me A2,A1;     B2;B1;    etc....


 int handle=FileOpen(Archivo_Historical(),FILE_READ|FILE_CSV);
      for(int i=0;i<5;i++)
           Alert("Fecha= ",FileReadString(handle),"Percentaje= ",FileReadString(handle));
whroeder1 2015.12.15 19:29  
The order the Alert parameters are created is not specified. Try:
string A=FileReadString(handle);
string B=FileReadString(handle);
Alert("Fecha= ",A,"Percentaje= ",B);
Carl Schreiber
Carl Schreiber 2015.12.15 19:43  

Normally a csv file is organised in rows (lines ended by \n) and delimiters like ';'

I read those files by (without testing, without error checking)

int hdl  = FileOpen(FileName,FILE_READ|FILE_CSV|FILE_COMMON); 
uint sz  = FileSize(hdl);
string s = FileReadString(hdl,sz),  l[]/*line array*/,c[]/*column array*/; 
int nl   = StringSplit(strFile,'\n',l), nc; // no lines and no. columns
while(nl-->0) { // => last line first
     nc  = StringSplit(l[nl],';',c), nc;
     while (nc-->0) { // last column first
         string col = c[nc];

To add comments, please log in or register