'allnd.txt' fwrites~ ; ,&LF each allnd

This works perfectly, and it is the most efficient yet. Thanks Ric.

Skip

On Thu, Nov 10, 2011 at 9:29 PM, Ric Sherlock <[email protected]> wrote:

> On Fri, Nov 11, 2011 at 7:24 AM, Skip Cave <[email protected]>
> wrote:
> > allnd is a boxed text array. The following function moves that array
> into a
> > text file and save that file on my disk.
> >
> > (5!:5 <'allnd') 1!:2 <'c:\test1\allnd.txt'
> >
> > However, the text file has all of the boxed text strings separated by a
> '|'
> > character.
> > How can I save the text file with line feeds in the file, instead of the
> > vertical bar character?
>
> If I'm wanting to write text to files for use/editing outside J, I
> tend to use the file reading/writing utilities from the 'files.ijs'
> script rather than the bare 1!:x foreign. In J7 they are automatically
> loaded at boot. In J6 you need:
>   require 'files'
>
> If your boxed text array is a simple list (rank 1) then:
>   'allnd.txt' fwrites~ ; ,&LF each allnd  NB. write the file to disk
>   allnd=: 'b' freads 'allnd.txt'          NB. read the back in from disk
>
> If your boxed text array is a table (rank 2) then you could use the
> 'tables/csv' or 'tables/dsv' addon
> http://www.jsoftware.com/jwiki/Addons/tables/dsv
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to