cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Ole_Luehn
Level III

How to change the path for saving / opening file in JMP 19 / Python script

Dear,

I run the following script in JMP19 and now in the file the script gets stuck at the bold line below. 

The table results.json is on my desk-top. I tried to copy the file and path to a different storage location. 

It still gets stuck.

In JMP 19 the script was working as it is...

Do you now how to change it?

I think that I need to tell the script to save the file into the Python path in the JMP19 folder on my, computer,....maybe?


with open("results.json", "w+") ......

Best wishes,
Ole

2 REPLIES 2
Ole_Luehn
Level III

Re: How to change the path for saving / opening file in JMP 19 / Python script

Sorry. I meant in JMP 18 it was working... 

Re: How to change the path for saving / opening file in JMP 19 / Python script

A little clarification please. You indicate the script now gets stuck in JMP 19, further down you indicate, in JMP 19 the script was working as is...?   I'm assuming you mean it hangs in JMP 19 but was working in 18?  Always helpful to have the full version numbers since we do make security and bug fix releases such as 19.0.1.

What is supposed to happen, is that the file would be saved to the same directory as the JSL script.  Running the JSL script would set the current working directory to the location of the jsl script, and without additional path components on the Python open() would default to saving in the same directory as the JSL.  If your JSL isn't pulling further JSL files as includes, you could even use Python commands to change the current working directory. 

On the Python side of things you can easily specify the full path to the file, including use of special directories.  

import jmp
import os

...

# using os.path.join() makes path portable on macOS and Windows on_desktop = os.path.join( jmp.DESKTOP, 'results.json') with open( on_desktop, 'w+' as f: f.write( str(response.primary_results[0])) ..

Recommended Articles