> From: Robert O'Boyle
> 
> I have J tables which I would like to place into various documents
> (e.g.
> WORD). Here is an example
> 
> I'd like to be able to directly copy in_data into a document. How can I
> do this in J?
>
> I routinely move data back & forth between EXCEL and J. Here, it's the
> formatted table that I am interested in moving.

A simplistic solution might be to convert in_data to say a TAB-delimited 
character list, use the clipboard to copy it to your Word document and then use 
"Convert Text to Table" to create a table. You would have to add the desired 
border formatting of course.
load 'tables/dsv'
wdclipwrite (TAB;'') makedsv |:> ,&.>/ ,@(8!:0) &.>  in_data

This may be way off base but maybe Inverted Tables 
"http://www.jsoftware.com/jwiki/Essays/Inverted%20Table"; would be a useful way 
of storing & manipulating your data?

Vars=: ;:'age pr m caa_waa pop_waa per_mat'
Data=: age;pr;m;caa_waa;pop_waa;per_mat
Labels=: 'AGE';'PR';'M';'Catch WAA';'Pop WAA';'% Mat at Age'
Formats=: '3.0';'8.3';'8.3';'8.3';'8.3';'8.3'

   Labels ,: ,.&.> Data
+---+-----+---+---------+-------+------------+
|AGE|PR   |M  |Catch WAA|Pop WAA|% Mat at Age|
+---+-----+---+---------+-------+------------+
| 2 |0.474|0.2|0.766    |0.766  |   0        |
| 3 |0.632|0.2|1.017    |1.017  |   0        |
| 4 |0.737|0.2|1.727    |1.727  |0.25        |
| 5 |0.895|0.2|2.514    |2.514  | 0.5        |
| 6 |0.947|0.2|3.287    |3.287  |0.75        |
| 7 |0.947|0.2|3.994    |3.994  |   1        |
| 8 |    1|0.2|4.806    |4.806  |   1        |
| 9 |    1|0.2|5.607    |5.607  |   1        |
|10 |    1|0.2|6.481    |6.481  |   1        |
|11 |    1|0.2|8.046    |8.046  |   1        |
+---+-----+---+---------+-------+------------+

   afi =: |:@:(<"_1@>)             NB. atoms from inverted

   (TAB;'') makedsv Labels, ((<'3.0'),(5$<'8.3')) (8!:0) afi Data
Or 
   (TAB;'') makedsv Labels, Formats (8!:0) afi Data
AGE     PR      M       Catch WAA       Pop WAA % Mat at Age
  2        0.474           0.200           0.766           0.766           0.000
  3        0.632           0.200           1.017           1.017           0.000
  4        0.737           0.200           1.727           1.727           0.250
  5        0.895           0.200           2.514           2.514           0.500
  6        0.947           0.200           3.287           3.287           0.750
  7        0.947           0.200           3.994           3.994           1.000
  8        1.000           0.200           4.806           4.806           1.000
  9        1.000           0.200           5.607           5.607           1.000
 10        1.000           0.200           6.481           6.481           1.000
 11        1.000           0.200           8.046           8.046           1.000

   wdclipwrite (TAB;'') makedsv Labels, Formats (8!:0) afi Data

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

Reply via email to