Hi,
[...] But it keeps checking only once.[...]
Hi,
By using FileIsLineEnding and moving all rows in CSV to first row it works.
But that is not the solution.
FileIsEnding is not working as expected. Please help
int handle string testfile = "test.csv"; void readfile() { string name; handle=FileOpen(testfile,FILE_CSV|FILE_READ,","); if(handle<0) { if(GetLastError()==4103) Print("No file named " + testfile); else { Print("Error while opening file" + testfile); return; } } int count; while(FileIsEnding(handle)==false) { name=FileReadString(handle); count=count+1; } Alert(count); // This alerts 1 if FileIsEnding is used. If FileIsLineEnding is used and all values moved to first row in CSV, then it works fine) FileClose(handle); }
FileIsEnding is not working as expected. Please help
I have tweaked your code so there is a test harness as well. It all works as expected for me as a script.
#define TESTFILE "test.csv" int steps=0; int start(){ for( int n=0; n<5; n++ ){ readFile(); Sleep(5000); } return(0); } void readFile(){ string name; int handle=FileOpen( TESTFILE,FILE_CSV|FILE_READ,"," ); if( handle<0 ){ if( GetLastError()==4103 ){ Print("No file named " + TESTFILE); } else{ Print("Error while opening file" + TESTFILE); } return; // if the handle is invalid then we quit, regardless of the type of error } int count=0; // the counting can't work if count is not initialised! while( FileIsEnding(handle)==false ){ name=FileReadString(handle); count++; } steps++; Print("read count is " + count + ": steps=" + steps); Alert(count); // This alerts 1 if FileIsEnding is used. If FileIsLineEnding is used and all values moved to first row in CSV, then it works fine) FileClose(handle); }
I have tweaked your code so there is a test harness as well. It all works as expected for me as a script.
Hi,
Finally I found the answer.
The file I was using was a xls file renamed to .csv and that didnt work as expected.
So i created a file first via an EA and then used it to add my data and it works !!!
for some reason FileIsEnding is not getting working if we rename the file.
Thanks for your help anyway.
Hi,
Finally I found the answer.
The file I was using was a xls file renamed to .csv and that didnt work as expected.
So i created a file first via an EA and then used it to add my data and it works !!!
for some reason FileIsEnding is not getting working if we rename the file.
Thanks for your help anyway.
An xls file is not a csv file . . . just because you change the extension it doesn't change the file contents . . nor would it if you change an xls to a jpg
A csv file has Comma Separated Values . . nothing else . . .
Semi-technical - old school notes.
There are two accepted formats for recognizing the end of the line carrage return and linefeed or just linefeed on its own in (and my memory is not clear on this) UNIX or 'C' type programming seneros. Most Text files indicate the end of file (EOF) with a character 27. If for some reason the file size on the file alocation table (FAT) is being used to determine the EOF and the character 27(ESC) is missing diferent ideas in how to handle when the file has ended can cause confusion.
An xls file is not a csv file . . . just because you change the extension it doesn't change the file contents . . nor would it if you change an xls to a jpg
A csv file has Comma Separated Values . . nothing else . . .
Hi RaptorUK
I was not having an option to save a new xls as .csv... so i did that and wasted 3 days troubleshooting this :((
Hi RaptorUK
I was not having an option to save a new xls as .csv... so i did that and wasted 3 days troubleshooting this :((
When you do a Save As you get the option to change the filetype to a previous versions of Excel or CSV in a drop down Box list of options.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to read a file on every tick.
Above is the code, But it keeps checking only once. I am calling this function from Start().
Please can someone tell what is wrong.