cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
lala
Level VII

Does python write data from memory to JMP only in a circular form?

import jmp;file_path = r"C:\0\test.txt"
data = []
with open(file_path, 'r') as file:
    for line in file:
        row = line.strip().split('\t')
        data.append([float(row[0]), float(row[1])])
dt = jmp.DataTable("New Table", len(data)) 
col_A = dt.new_column('A', jmp.DataType.Numeric)
col_B = dt.new_column('B', jmp.DataType.Numeric)
for i, (a, b) in enumerate(data):
    dt['A'][i] = a
    dt['B'][i] = b

 

 

 

Does this form work as in the original JSL code?

dt[0,0] = data[0,0]

Thanks Experts!

 

4 REPLIES 4
lala
Level VII

Re: Does python write data from memory to JMP only in a circular form?

I try it,not word.

import jmp;file_path = r"C:\0\test.txt"
data = []
with open(file_path, 'r') as file:
    for line in file:
        row = line.strip().split('\t')
        data.append([float(row[0]), float(row[1])])
r=len(data)
print(f"num {b}")
jmp.run_jsl("""
ar=Python Get(date[]);r=Python Get(b);
d2=New Table("test",Add Rows(r),New Column("A"),New Column("B"));
d2[0,0] = ar[0,0]

""")
jthi
Super User

Re: Does python write data from memory to JMP only in a circular form?

Scripters Club Recording: Running Python Code within JSL, there are examples in your JMP installation folder \18\Samples\Scripts\Python and I think some in scripting guide Additional JSL-to-Python Examples (jmp.com). More can be found from many presentations by Paul (I also mention these in my presentation from Scripters Club)

-Jarmo
lala
Level VII

Re: Does python write data from memory to JMP only in a circular form?

This loop form of the code I posted is already implemented.

I'm just wondering if python has this feature

dt[0,0] = data[0,0]

 

Experts said that I have seen these content, but my English skills are poor, and programming knowledge is not much.Still not solved.

If I had found a way, I wouldn't have spent so much time writing this post.

 

So ask the experts if they can help.

jthi
Super User

Re: Does python write data from memory to JMP only in a circular form?

Which feature? Data table subscripting and setting all values of data table from matrix?

You can set all values with run_jsl

import jmp

file_path = r"C:\Users\jarmo\Downloads\test(1).txt"
data = []

with open(file_path, 'r') as file:
    for line in file:
        row = line.strip().split('\t')
        data.append([float(row[0]), float(row[1])])

jmp.run_jsl("""
m = Python Get(data);

dt = New Table("test", 
	Add Rows(N Items(m)),
	New Column("A"),
	New Column("B")
);
	
dt[0,0] = m
""")
-Jarmo