-
Reading News from a CSV file 6 replies
Reading CSV into Indicator Buffer 4 replies
Reading/writing files in any folder - MT4 build 600+ 0 replies
.CSV Files Editing and Reading 2 replies
int h = FileOpen(FileName, FILE_CSV|FILE_READ,'~');
if (h==0) Comment("File "+FileName+" not found.");
// First pass loads data from file into arrays dt, val (i.e. date/time, and value)
for (int c=0; !FileIsEnding(h) && c<9999; c++) {
string tmp = FileReadString(h);
if (FileIsEnding(h)) break;
if (StringLen(StringTrimRight(tmp)) < 1) continue; // <<<<==== ADD THIS LINE OF CODE
StrToStringArray(tmp,arr,",");
int tc = StrToInteger(StringSubstr(arr[0],0,10));
dt[c] = StrToTime(TimeToStr(tc,TIME_DATE|TI ME_MINUTES|TIME_SECONDS));
val[c] = StrToNumber(arr[1]);