I am trying to read the last line time value from a csv file. Check the following:
2018-07-26 11:04:00 1.17272 1.17275 1.17267 1.17272
2018-07-26 11:05:00 1.17272 1.17273 1.17265 1.17268
2018-07-26 11:06:00 1.17268 1.17273 1.17261 1.17264
The above is sample data. I have tried the following code and the result is as follows:
int file = FileOpen("latest.csv",FILE_READ|FILE_SHARE_READ|FILE_CSV|FILE_COMMON);
if(file != INVALID_HANDLE)
I m not getting the complete date value. Even if I try to increase the offset of the FileSeek()function.
Kindly, let me know how is it possible to read the csv file's last line.
Thank you for your references. But it could have been more helpful if you have come up with something that will help. I have read many articles here but none was helpful to me. Hence, I have asked the question here. Please help me.
I do not know the answer directly maybe you have to specify the delimiter see: https://www.mql5.com/en/docs/files/fileopen
It seems to be a space in stead of the regular comma as in csv comma separated values.
You want to use commas separated values without using a comma to separate them.
You could try to specify the delimiter as being a space.
string file_name, // File name
int open_flags, // Combination of flags
short delimiter='\t', // Delimiter
uint codepage=CP_ACP // Code page
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Особенности языка mql5, тонкости и приёмы работы
fxsaber, 2018.04.06 17:08
// Заполнение массива строками из файла - альтернатива
int FileToStrings2( const string FileName, string &Str )
return(FileLoad(FileName, Bytes) ? StringSplit(CharArrayToString(Bytes), '\n', Str) : 0);
int Amount = FileToStrings2("Test.csv", Str);
Print(Str[Amount - 1]);
I tried it sir. But didn't worked for me.
Show the code.
The chance is extremely slim that the answer is not in one of these 244 search result pages.
I used to be able to solve 90% of the issues by just doing some searches.
You can also scoop over one of the quality articles for example this: https://www.mql5.com/en/articles/2720
Scroll down to the part: