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

David Thompson dthmpsn1 at illinois.edu
Thu Jul 31 12:18:32 PDT 2008


>Although I have been using ProVue apps for over 20 years (damn that 
>makes me old), I have no experience with ArrayBuild.  I suppose it 
>would behoove me to at least learn what it does (my to-do list is a 
>queue rather than a stack).

This would be well worth learning. ArrayBuild, 
and ArrayFilter are amazingly powerful and useful 
tools. The newer CharacterFilter, and ChunkFilter 
commands are pretty useful too.

>
>In any case, the fileload route worked beautifully on a smaller data 
>subset, but when I tied it with my full data which includes a 2.9 Meg 
>csv file I get an "Expression stack overflow."
>
>Is that too large a file for this sort of solution?

As Peter Harden has already mentioned, it's not 
too large, but you do need to take some 
additional steps. Further information on this can 
be found on page 1573 of the Panorama Handbook, 
"Reading Really Big Data Files." There is an 
error in the example on this page. Instead of

local  myFile,myFileSize
myFileSize= filesize( "","MyPicture.jpg")
if  myFileSize > info("expressionstacksize" ) * 2
     expressionstacksize myFileSize * 2
     if  error
         message  info("error")
         rtn
     endif
endif
myFile= fileload( "","MyPicture.jpg")


it should be something like this.

local  myFile,myFileSize
myFileSize= filesize( "","MyPicture.jpg")
if  myFileSize > (info("expressionstacksize" ) -1000)/ 2
     expressionstacksize myFileSize * 2  + 1000
     if  error
         message  info("error")
         rtn
     endif
endif
myFile= fileload( "","MyPicture.jpg")

The number 1000 in my corrected version is an 
arbitrary number, and in most cases you should be 
able to get by with a smaller number, but it will 
*always* need to be more than zero.

The expression stack would also be an issue with 
my ArrayBuild example. Here is an amended version.

Local theText,folder,file
file="YourFileName.csv"
ArrayBuild theText,chr(1),"",formula
If 2 * sizeof("theText") > info("expressionstacksize") - 1000
     ExpressionStackSize 2 * sizeof("theText")+1000
EndIf
theText="Your header"+chr(13)+replace(theText,chr(1),"")
SaveFileDialog folder,file,"Save this file as:"
If file = "" stop endif
FileSave folder,file,"",theText

Dave


More information about the Qna mailing list