User error, same file for many symbols, was:Not all rows written using fput

Hi I m using the example found on forum and based on the example I tried to export all rows to file, but it only write the same ticker. Please help how to fix it in order to export all rows?

`AddColumn(C,"C",1,colorDefault,colorDefault);

fh = fopen( "c:\temp\data.csv", "w");
if(fh)
{
fputs("Ticker\n", fh );
bir = Status("barinrange");
for( i = 0; i < BarCount; i++ )
{
fputs( Name()+"\n", fh);
}
fclose( fh );
}

Filter=1;
`
the explore result:
1

the file written:
2

The formula is wrong. You are using SAME hard coded file name data.csv but you run on multiple symbols. So that single file gets overwritten over and over again and result is just LAST symbol data stored.

You should be using DIFFERENT file names. Also \ is escape character can not be used alone. File paths require \\ to encode single backslash.

fh = fopen( "c:\\temp\\" + Name() + ".csv", "w");

Last but not least:

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors. You failed to post code correctly and some parts (including file paths) are wrong.

If you want to export data you should read the Knowledge Base, it contains lots of articles about it:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.