Yuvaraj Athur Raghuvir wrote: > 1) Input file: > aaa bb cccc dd e > 1111 22 33333 444 55555 6 7 8 > > 2) Read input as an array of values. > > data =: cut"1 'm' freads y NB. y is the fully qualified file name > > data > +----+--+-----+---+-----+-+-+-+ > |aaa |bb|cccc |dd |e | | | | > +----+--+-----+---+-----+-+-+-+ > |1111|22|33333|444|55555|6|7|8| > +----+--+-----+---+-----+-+-+-+ > > 3) Now, pad the matrix in a way similar to $ operator for each dimention. > So, end result should look like: > +----+--+-----+---+-----+----+----+-----+ > |aaa |bb|cccc |dd |e | aaa| bb |cccc | > +----+--+-----+---+-----+----+----+-----+ > |1111|22|33333|444|55555|6 |7 |8 | > +----+--+-----+---+-----+----+----+-----+
The expression cut"1 'm' freads y pads out the first row with empties so that it matches the length of the second row. Better not to pad at all, but use reshape: dat=. 'b' fread 'temp/t1.txt' dat=. cut each dat len=. >./ # &> dat len $ &> dat +----+--+-----+---+-----+---+--+----+ |aaa |bb|cccc |dd |e |aaa|bb|cccc| +----+--+-----+---+-----+---+--+----+ |1111|22|33333|444|55555|6 |7 |8 | +----+--+-----+---+-----+---+--+----+ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
