Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 for iPad and trade anywhere!
Luis
226
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....

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);
whroeder1
13644
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
5960
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