In the JMP python script editor, what is the code, after 'import jmp' that points to the open jmp table I want to read and write to with code? I thought it would be simple and 'native' to JMP python. I get 'no open table'
Thanks to those who responded to help. I did get it to 'open' the table I wanted. For those who might be able to use what I came up with to open the jmp table, then export column entries to a third-party web site to extract data from the pages related to each column entry, here is a general form of the Python code I worked out. I am still working on getting the output to load directly back into the jmp table rather than extracting it from the log, although such log extraction does allow for editing.
import jmpfrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.common.exceptions import TimeoutException
# Set up Selenium WebDriveroptions = Options()options.headless = False # Runs Safari in visible mode for debugging
# Initialize the WebDriver (Safari)driver = webdriver.Safari()
# Path to the JMP file (adjusted to the path you provided)file_path = "/YOUR JMP PATH.jmp"
# Open the specific table by file pathdt = jmp.open(file_path) # Open the table directly from the file
# Access the 'YOUR_COLUMN' column from the open tableYOUR COLUMN_column = dt["YOUR COLUMN"] # Correct syntax for accessing a column
# Initialize a list to store the results (YOUR NEW COLUMNS)
results = []
# Function to extract YOUR DATA:url = f'https://www.YOUR WEB PAGE TO EXTRACT FROM'
try:# Open the URLdriver.get(url)# Set a short timeout (e.g., 5 seconds) to wait for the page to loadWebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH, "//a[contains(@href, 'YOUR_KEY')]")))
# Adjust XPath to grab the correct link (e.g., get the first match)YOUR_tag = driver.find_element(By.XPATH, "//a[contains(@href, 'YOUR_KEY') and not(contains(@href, 'access'))]") # Exclude 'access' related linksYOUR_KEY = YOUR_TAG.text.strip() # Extract the text of YOUR KEY
return YOUR_OUTPUTexcept TimeoutException:print(f"Timeout error for YOUR_COLUMN {YOUR_COLUMN}: URL did not load within the specified time.")return None, None # If the URL doesn't load, return None YOUR TAGSexcept Exception as e:print(f"Error extracting YOUR TAGS for YOUR_COLUMN {YOUR_COLUMN}: {e}")return None, None
# Iterate over each rowYOUR_OUTPUT = get_YOUR_OUTPUT(YOUR_COLUMN)results.append((YOUR_OUTPUT)) # Store the result as a tuple
# Print the resultsprint(f"YOUR_COLUMN: {YOUR_COLUMN} -> YOUR_TAG: {YOUR_NEW_DATA})
# Close the WebDriver after processing all the entriesdriver.quit()
Scripting Index and Scripting Guide do have examples for this
import jmp jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp') print(jmp.current())
Scripting Guide > Python > Working with JMP Data Tables > Using Operators to Test JMP Objects (not the best example)
Scripting Guide > Python > Python Syntax Reference > jmp Package Functions
The import jmp package is the interface layer between the Python scripts and JMP internals. An entire Python category has been added to the Scripting Index. This section provides documentation and examples for interacting with JMP from Python. The Python Integration is a continuing work in progress. JMP 18 focuses primarily on the minimum necessary set of capabilities. Package installation, Data Table interaction, transfer of data between JMP and Python. JMP 19 expands on this with additional data table column support, better interaction with data frames, additional JMP -> Python, Python -> JMP data type support, and other new capabilities...
You have the results, there are multiple ways to put that directly into a data table.
To set a specific cell value in a table
dt['col_name'][ row# ] = value
Remember in Python indexing is zero-based, where in JSL it is one-based. So the first row from Python is dt['col'][0]
Or set an entire column at a time from a list
dt['col'] = results
With the above the length of results must match the data tables number of rows, len(results) == dt.nrows
Also, dt's data type must match that of the elements of the list, which must all be of the same type.
New data tables can be created from Python, as can new columns and rows.