cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to use Accelerated Life Testing (ALT) to evaluate reliability. Register for June 5 webinar, 2pm US Eastern Time.

Discussions

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

How to write .jmp files with JMP python

Hi,   I am using JMP19.1.1

I see examples of how to use JMP or JSL to open files, add jsl scripts for plotting and then run them.

Are there examples to use JMP Python to open csv files and write .jmp files with charts in them?   What do people do?   

Adrian

7 REPLIES 7
jthi
Super User

Re: How to write .jmp files with JMP python

Saving can be done with save method of DataTable 

jthi_0-1780425137594.png

To add table scripts you can use either run_jsl or scripts with jmp.Expression

jthi_1-1780425229292.png

 

-Jarmo

Re: How to write .jmp files with JMP python

Hi,

Thanks for responding.  I am talking about not using the jmp libraries.   I am talking about using python code that is processing data, that spits out csv files.   I want to switch to writing .jmp files.   Is there a way to do this?   i.e.  Pandas dataframe directly to .jmp ?   

Thanks

jthi
Super User

Re: How to write .jmp files with JMP python

To my knowledge no. You would need to run the Python inside JMP.

-Jarmo

Re: How to write .jmp files with JMP python

Here is what I try to run:

from pathlib import Path
import jmp

csv_path = Path(r"C:\Work\debug\jmp_debug\CT_Pro_PRO0CV2_pass_fail_05302026.csv")
out_path = Path(r"C:\Work\debug\jmp_debug\CT_Pro_PRO0CV2_pass_fail_05302026.jmp")

print("Opening:", csv_path)

dt = jmp.open(str(csv_path))

print("Saving:", out_path)

dt.save(str(out_path))

print("Done")     

I run it this way:  & "C:\Program Files\JMP\JMP\19\jmp.exe" -R "C:\Work\debug\jmp_debug\jmp_csv_to_jmp_simple.py" in powershell.   The problem is this pops up three windows.        Do you know if there is anyway to run JMP in a headless fashion?    I.e.  Run it and not have a collage of windows pop open ?

 

Re: How to write .jmp files with JMP python

The main reason to go directly to .jmp is these files are 4-10 GB in csv format.  So this is painful.   Ideally, we could pass a pandas dataframe to the jmp table and write it

 

Re: How to write .jmp files with JMP python

This is really painful.  It appears there is no real way to make this run in a headless fashion.  This is really surprising.   I must me wrong and not have the right documenation.  If someone has information on how to run jmp in a headless fashion, this would be really helpful.  I.e.  I can run this in a script and not get three to four new windows popping open.

Re: How to write .jmp files with JMP python

In JMP 19.1.3, and plain vanilla Python 3.13.3 (Non JMP), I got the following improvement.  This only pops up the .jmp table being created.  So this is close to a solution.   I would really still like to know if there is headless information ?  

from pathlib import Path
import time

import win32com.client


def jsl_quote(path_or_text) -> str:
text = str(path_or_text)
text = text.replace("\\", "\\\\").replace('"', '\\"')
return f'"{text}"'


csv_path = Path(r"C:\Work\debug\jmp_debug\05302026.csv")
out_path = Path(r"C:\Work\debug\jmp_debug\05302026.jmp")

jmp = win32com.client.Dispatch("JMP.Application")

# Try False first. If nothing works, set True while debugging.
jmp.Visible = False

jsl = f"""
Names Default To Here( 1 );

dt = Open({jsl_quote(csv_path)},Invisible);

dt << Save As( {jsl_quote(out_path)} );

Close( dt, No Save );
"""

print("Running JSL...")
jmp.RunCommand(jsl)

# Give JMP a moment if RunCommand returns before save completes.
time.sleep(2)

print("Saved?", out_path.exists(), out_path)

Recommended Articles