Thank you! Just the information I needed! Esa -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Henry Rich Sent: 28.06.2008 20:00 To: 'Programming forum' Subject: RE: [Jprogramming] Problem with the last column of a tab delimetedfile
The problem is that 'm' freads is returning a table. This table must have lines of the same length, so the short ones are being padded with spaces. You need to use 'b' freads which will box the lines so that they can have different lengths. Or, you can just do 1!:1 to read your file, something like <;._2@(,&TAB) ;._2 (1!:1) filename Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Lippu Esa > Sent: Saturday, June 28, 2008 9:22 AM > To: Programming forum > Subject: [Jprogramming] Problem with the last column of a tab > delimeted file > > Hi! > > I'm trying to read a tab delimited file from Excel. > > It contains empty columns at the end of the lines (except the header > line). > > However, the last empty column contains blanks that I must trim away. > > No big deal but I'd like to know how to read the file "by the book". > > I read the file like this: > > tab=.9 { a. > > tbl=: <;._2 "1 (,.&tab 'm' freads 'test.txt') > > ]hdr=.{.tbl > +--+-+--+--+ > |id|c|a1|a2| > +--+-+--+--+ > > ]dat=.}.tbl > +-+-++-----+ > |1|a|| | > +-+-++-----+ > |2|b|| | > +-+-++-----+ > |3|c|| | > +-+-++-----+ > > This is the file test.txt (^I=tab, $=LF): > > id^Ic^Ia1^Ia2$ > 1^Ia^I^I$ > 2^Ib^I^I$ > 3^Ic^I^I$ > > The J version is 6.01c (j 6.02a downloaded, not yet installed) > > Any suggestions? > > Esa > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
