Why mql4 is reading this backwards? File operations

Back to topics list To post a new topic, please log in or register
avatar
83
BeLikeWater 2015.12.15 19: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....

why??

 int handle=FileOpen(Archivo_Historical(),FILE_READ|FILE_CSV);
      for(int i=0;i<5;i++)
         {
           Alert("Fecha= ",FileReadString(handle),"Percentaje= ",FileReadString(handle));
         }
      FileClose(handle);
avatar
12998
WHRoeder 2015.12.15 20: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);

avatar
2017
gooly 2015.12.15 20: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];
         ...
     }
}



Back to topics list  

To add comments, please log in or register