cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Kenobi
Level III

Is it possible to save the journal or report file as a json file, or export it as a dictionary?

Hello,

 

I plan on using the some of the images, titles, tables from a journal, and use them in order to create a word document using external programming language like Python. I was wondering if JMP has a feature to export the journal as a json file, where each object is saved in a key value format.

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Is it possible to save the journal or report file as a json file, or export it as a dictionary?

You can save XML like this

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line( {Line Color( {212, 73, 88} )} ) );
xml = bv<<getxml;
file = savetextfile("$temp/teport.xml", xml);

XPATH can search the xml. The xml is a representation of the report's display box tree. It will not include pictures of the report, but you could gather those pictures from the <PictureBox> nodes that XPATH could locate. I think all the numbers in the report will be there, and they will require a bit of study to grab them:

<OutlineBox leftOffset=\!"0\!" topOffset=\!"19\!" width=\!"251\!" height=\!"124\!" helpKey=\!"Bivar Summary\!" isOpen=\!"true\!">Summary of Fit<TableBox leftOffset=\!"14\!" topOffset=\!"29\!" width=\!"237\!" height=\!"97\!">
            <StringColBox width=\!"172\!" height=\!"95\!">
              <StringColBoxHeader></StringColBoxHeader>
              <StringColBoxItem>RSquare</StringColBoxItem>
              <StringColBoxItem>RSquare Adj</StringColBoxItem>
              <StringColBoxItem>Root Mean Square Error</StringColBoxItem>
              <StringColBoxItem>Mean of Response</StringColBoxItem>
              <StringColBoxItem>Observations (or Sum Wgts)</StringColBoxItem>
            </StringColBox>
            <NumberColBox leftOffset=\!"172\!" topOffset=\!"0\!" width=\!"64\!" height=\!"95\!">
              <NumberColBoxHeader></NumberColBoxHeader>
              <NumberColBoxItem>0.502917</NumberColBoxItem>
              <NumberColBoxItem>0.489836</NumberColBoxItem>
              <NumberColBoxItem>15.85786</NumberColBoxItem>
              <NumberColBoxItem>105</NumberColBoxItem>
              <NumberColBoxItem>40</NumberColBoxItem>
            </NumberColBox>
          </TableBox>
        </OutlineBox>

pairing up Root Mean Square Error with 15.85786

Table Box with two columnsTable Box with two columns

will require loading both columns of the table. There won't be a key for Root Mean Square Error, but there is a way to find it.

 

This is an example of how XML and JSON are nearly identical languages (tree structured, tags ) but in practice XML tends to represent reports while JSON tends to represent data.

 

If you build something cool that you can share, maybe you can do a presentation at a JMP conference!

Craige

View solution in original post

3 REPLIES 3
Craige_Hales
Super User

Re: Is it possible to save the journal or report file as a json file, or export it as a dictionary?

You can save XML like this

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line( {Line Color( {212, 73, 88} )} ) );
xml = bv<<getxml;
file = savetextfile("$temp/teport.xml", xml);

XPATH can search the xml. The xml is a representation of the report's display box tree. It will not include pictures of the report, but you could gather those pictures from the <PictureBox> nodes that XPATH could locate. I think all the numbers in the report will be there, and they will require a bit of study to grab them:

<OutlineBox leftOffset=\!"0\!" topOffset=\!"19\!" width=\!"251\!" height=\!"124\!" helpKey=\!"Bivar Summary\!" isOpen=\!"true\!">Summary of Fit<TableBox leftOffset=\!"14\!" topOffset=\!"29\!" width=\!"237\!" height=\!"97\!">
            <StringColBox width=\!"172\!" height=\!"95\!">
              <StringColBoxHeader></StringColBoxHeader>
              <StringColBoxItem>RSquare</StringColBoxItem>
              <StringColBoxItem>RSquare Adj</StringColBoxItem>
              <StringColBoxItem>Root Mean Square Error</StringColBoxItem>
              <StringColBoxItem>Mean of Response</StringColBoxItem>
              <StringColBoxItem>Observations (or Sum Wgts)</StringColBoxItem>
            </StringColBox>
            <NumberColBox leftOffset=\!"172\!" topOffset=\!"0\!" width=\!"64\!" height=\!"95\!">
              <NumberColBoxHeader></NumberColBoxHeader>
              <NumberColBoxItem>0.502917</NumberColBoxItem>
              <NumberColBoxItem>0.489836</NumberColBoxItem>
              <NumberColBoxItem>15.85786</NumberColBoxItem>
              <NumberColBoxItem>105</NumberColBoxItem>
              <NumberColBoxItem>40</NumberColBoxItem>
            </NumberColBox>
          </TableBox>
        </OutlineBox>

pairing up Root Mean Square Error with 15.85786

Table Box with two columnsTable Box with two columns

will require loading both columns of the table. There won't be a key for Root Mean Square Error, but there is a way to find it.

 

This is an example of how XML and JSON are nearly identical languages (tree structured, tags ) but in practice XML tends to represent reports while JSON tends to represent data.

 

If you build something cool that you can share, maybe you can do a presentation at a JMP conference!

Craige
Craige_Hales
Super User

Re: Is it possible to save the journal or report file as a json file, or export it as a dictionary?

You might find it easier to use VBA to automate JMP to get the reports you need into a word doc.

You might be able to create the exact report you need and save it directly as a word doc.

You might save the report as HTML and get everything (including the pictures). I've never used Beautiful Soup, but I believe it might give you a way to grab bits out of the HTML from Python.

JSL is certainly capable of creating a JSON file of any parameters you want to send to Python; use a JSL associative array:

Write( As JSON Expr( ["a" => "z", "b" => ["c" => 3, "d" => 5]] ) );

{"a":"z","b":{"c":3,"d":5}}

 

 

 

Craige
Kenobi
Level III

Re: Is it possible to save the journal or report file as a json file, or export it as a dictionary?

Thank you very much. This is something that I can work with. Glad to know the report can be saved in HTML report. As you mentioned, I am planning to use BeautifulSoup for parsing.