Greetings,
Just 3 days ago I had a similar problem.
The following worked a treat! I defined
J2csv =: [: ; [: (LF ,~ }:)each [: ,each/"1 ',' ,~each ":each
And then produced the table like so -
J2csv i.5 7
0,1,2,3,4,5,6
7,8,9,10,11,12,13
14,15,16,17,18,19,20
21,22,23,24,25,26,27
28,29,30,31,32,33,34
and also
J2csv 'ABCDE',.&:(<"0) i.5 7
A,0,1,2,3,4,5,6
B,7,8,9,10,11,12,13
C,14,15,16,17,18,19,20
D,21,22,23,24,25,26,27
E,28,29,30,31,32,33,34
Copy/paste output from J session into word processor.
Select all the rows of the comma separated table
Insert
Table
Convert text to table
Number of columns => 8 (pre-set)
Number of rows => 5 (pre-set)
Separate text at
(x) comma
Touch OK
All the text in the table should be grid cell aligned in a table.
Get the word processor to do the alignment and justification in
paragraph mode of all the cells.
Optionally delete the grid sell boundary lines and adjust cell sizes by
selecting all cells..
NOTES:
J2csv works on 1D and 2D numeric and text arrays as expected.
J2csv also works for 1D and 2D boxed arrays.
If any cell contains a comma or LF then you will need extra coding or manual
intervention.
J2csv will work for higher dimensions, but does not insert blank lines
between those higher dimensions.
Ian
-----Original Message-----
From: General <[email protected]> On Behalf Of Fraser Jackson
Sent: Tuesday, 21 April 2020 12:45 PM
To: [email protected]
Subject: Re: [Jgeneral] Transferring J output to other documents
Thanks for your comments Bob.
If you use
Z =. ?. 4 5 $ 200 as a test array, Copying a display of z to Word leads to
an array which is like a ;ist of four vectors. The columns are no longer
aligned. You can do better with using the display of <”0 z after having
chosen to toggle ascii box characters in the view menu, but it still does not
give clean box shapes by default even with a monospaced font like Courier New.
For latex inserting the J session selection within a verbatim section often
gives a satisfactory output but not always..
Script sections for programs do provide accurate detail in Word even with some
loss of formatting. For Latex you need to use the verbatim control to avoid a
range of problems.
It is relatively simple to write a program to format the data in an array for
latex. If there is a box for each item in the array, both numeric and
character items can be entered in the Latex table and the formatting rules of
Latex used to format the table and generate all lines required. We need to add
some tidy capabilities to our packages to make it easy to transfer results to
whatever document forms are required. They are essential if we want to see
wider use of J.
Fraser
Sent from Mail for Windows 10
From: 'robert therriault' via General
Sent: Tuesday, April 21, 2020 12:45 PM
To: General forum
Subject: Re: [Jgeneral] Transferring J output to other documents
Hi Fraser,
For Word Documents I was able to just select the code on either the jQT or JHS
interfaces and then use Edit|Paste Special... in the Word document. I use html
format as my choice, but there are times that the unformatted provides a
cleaner look. For boxed information I think that you will want to use html to
retain spacing and linefeeds. I would guess that Latex has something similar,
although I am not a user of it.
If I have misread what it is that you are attempting, my apologies for the
noise.
Cheers, bob
> On Apr 20, 2020, at 16:48, bill lam <mailto:[email protected]> wrote:
>
> Not really but does print to pdf printer work?
>
> On Tue, Apr 21, 2020, 7:28 AM Fraser Jackson
> <mailto:[email protected]>
> wrote:
>
>> Does anyone have a simple way of copying formatted J session output
>> to a Word or Latex document .
>> It needs to preserve Ascii formatted boxes as well, but a means of
>> also transferring an item using line drawing characters would be very usefuf.
>>
>> Any suggestions would be most helpful.
>>
>> For Latex I have some simple functions for constructing a latex input
>> for tables for numeric cases, but intend to develop functions to
>> create latex input to display a boxed table for a wider range of simple
>> cases.
>>
>> Fraser
>>
>> Sent from Mail for Windows 10
>>
>> ---------------------------------------------------------------------
>> - 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential
and/or privileged information.
If you are not the intended recipient, please notify the sender and then delete
it immediately.
Any views expressed in this email are those of the individual sender except
where the sender expressly and with authority states them to be the views of
the NSW Office of Environment and Heritage.
PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm