Complex CSV export part 2 - the attack of the spurrious invisible characters

David Thompson dthmpsn1 at illinois.edu
Tue Jul 29 09:21:03 PDT 2008


>While I have a better grasp of what is not causing the mysterious 
>null strings, but feel no closer to solving them.
>
>Any more ideas?

Only a guess that it might have something to do with the fact that 
you are exporting more than one record per line. It may be a bug in 
SaveAsText.

An alternative method for creating this file would be to create the 
text with an ArrayBuild, tack on the header, and do a FileSave. You 
would use a non-printing character as your separator in the 
ArrayBuild so that they could be removed with a replace( function, or 
even a stripprintable( if it came to that. It might look something 
like this.

Local theText,folder,file
file="YourFileName.csv"
ArrayBuild theText,chr(1),"",formula
theText="Your header"+chr(13)+replace(theText,chr(1),"")
SaveFileDialog folder,file,"Save this file as:"
If file = "" stop endif
FileSave folder,file,"",theText

Where it says formula, you would use the formula you currently have 
in the data tile, without the enclosing {} braces.

If you still want to use SaveAsText and a form, you could follow the 
SaveAsText with code to load the file into a variable, clean out the 
non-printing characters, and save it back with a FileSave.

Local theText
theText = stripprintable(fileload(folder(thePath),file))
FileSave folder(thePath),file,"",theText

thePath would be the folder path of the file you saved with the 
SaveAsText, and file would be the name of that file.

Dave


More information about the Qna mailing list