---Hahn, Harvey wrote:
> Sent: Tuesday, 6 May 2008 09:59
> Consider the following file saves in Windows:
> q=. 1 2 3
> q fwrites jpath ('~user\data\q1.txt')
> 7 NB. 31 20 32 20 33 0d 0a = 1 2 3CRLF
> q writecsv jpath ('~user\data\q2.txt')
> 13 NB. 22 31 22 2c 22 32 22 2c 22 33 22 0d 0a = "1","2","3"CRLF
>
> I'd like the lines of saved data to be delimited by LF rather
> than CRLF.
> I checked the Primer, JforC, LearningJ, and stdlib. Interestingly,
> sometimes a comma was used and sometimes a space was used in
> examples--however, none of the following worked (always gave a domain
> error):
>
> (toJ,q) fwrites...
> (toJ q) fwrites...
> (toJ,q) writecsv...
> (toJ q) writecsv...
>
> Where am I going wrong here? Thanks in advance!
The verb fwrites (write a file as a string) takes the left argument and does a
toHOST on it (undoing your toJ) before writing to file. If you want to write
the actual content of the left argument without it being changed you should use
the fwrite verb instead.
(toJ,q) fwrite...
If you want to do a similar thing with the csv verbs then you might want to
look at the request for library change to csv.ijs on this page
http://www.jsoftware.com/jwiki/System/Library/Requests
Use makecsv and then use fwrite to write it.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm