Hi, Roger I'd express my admir to you first and I haven't expected quick a detailed instruction from you and it is so late there in Canada.
I realy had read of some related parts yesterday unfortunately I was guessing this to be approach for text files only, so I failed to give those piece of code examples a try, thinking mine a binary one. That works. Thank you! Best Regards, emp Roger Hui wrote: > > The approach in J is to read/write text files, > then convert the strings (character vectors) and > reshape as appropriate. For example: > > x=: 1!:1 <'\junk\x' NB. read a text file > $x NB. string of length 200 > 200 > 3!:0 x NB. type is 2 (literal) > 2 > y=: _2 (3!:4) x NB. convert to 4-byte integers > $y NB. 50 of them > 50 > 3!:0 y NB. type is 4 (integer) > 4 > +/y NB. can do arithmetic on it > _922886641 > > z=: 25 2$y NB. reshape into 2-column matrix > +/ z NB. sums of the 2 columns > _2325095959 1402209318 > > z1=: _2 ]\ y NB. another way to make 2 column matrix > $z1 > 25 2 > +/z1 > _2325095959 1402209318 > > > > ----- Original Message ----- > From: emptist <[email protected]> > Date: Thursday, August 20, 2009 21:19 > Subject: [Jchat] [newbie]how to read binary formatted file > To: [email protected] > >> >> Hi, >> >> I just started to learn J and some kdb/q in the meantime (with a >> Smalltalkbackground but not a programmer). In q I've learned to >> read a kind of binary >> formatted historical price data file, which contains 8 4 byte >> int data for >> each record, using: >> >> list: ("iiiiiiii";4 4 4 4 4 4 4 4) 1: `:path/filename >> >> and this will give me a list of data of the entire file. (For >> those not >> familiar with q, 1: reads binary file, and i stands for int type >> in q, while >> 4 means a field is 4 byte in size). >> >> I've not finished reading yet but my quick going through the J >> books for >> about 13 hours doesn't give me a quick solution in J. I think it >> might be >> wise to ask for help here. (By the way, I was reading into 3 >> o'clock this >> morning, here in China, Remembering Ken Iverson, by Roger Hui ...) >> >> Thanks in advance for any advice. >> >> Best Regards, >> >> Emp > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > -- View this message in context: http://www.nabble.com/-newbie-how-to-read-binary-formatted-file-tp25073648s24193p25074590.html Sent from the J Chat mailing list archive at Nabble.com. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
