Yuvaraj Athur Raghuvir wrote:
> This is regarding reading and working with data from files.
> (if text garbled, view it in Courier New font)
> 
> 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    |
> +----+--+-----+---+-----+----+----+-----+

may be this way, assume
a=: 0 : 0
aaa bb cccc dd e
1111 22 33333 444 55555 6 7 8
)

   ]data=. (<;._1)@(' '&,)@deb;._2 a
+----+--+-----+---+-----+-+-+-+
|aaa |bb|cccc |dd |e    | | | |
+----+--+-----+---+-----+-+-+-+
|1111|22|33333|444|55555|6|7|8|
+----+--+-----+---+-----+-+-+-+
   ({:@$data)&$@(-.&a:)("1) data
+----+--+-----+---+-----+---+--+----+
|aaa |bb|cccc |dd |e    |aaa|bb|cccc|
+----+--+-----+---+-----+---+--+----+
|1111|22|33333|444|55555|6  |7 |8   |
+----+--+-----+---+-----+---+--+----+

-- 
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to