txt = Hex( (Today() - Informat( "01/01/1970", "mm/dd/yyyy" ) - In Hours( 8 )) * 1000 + 600000 + Day( Today() ), base( 36 ) );
a = Today();
b = Informat( "01/01/1970", "mm/dd/yyyy" );
c = In Hours( 8 );
d = Day( Today() );
e = (a - b - c) * 1000 + 600000 + d;
f = Hex( (a - b - c) * 1000 + 600000 + d, base( 36 ) );I asked ChatGPT several times and the results were inconsistent with the JSL results.Only ask for help from experts who are familiar with both JSL and python.Thank you very much!
I have two questions for the experts:
1. How to concatenate two JMP tables in python?
2, how can the following python be modified to python asyncio asynchronous execution form?
Thanks Experts!
import jmputils
import jmp
from datetime import datetime, timedelta
today = datetime.today()
dates = []
for i in range(200):
dates.append((today - timedelta(days=i)).strftime('%Y%m%d'))
j = 0
for date in dates:
#print(date)
j += 1
jmp.run_jsl('''
b=Python Get(date);
d1=New Table("o",Add Rows(1),New Column("date",Set Values({b})));
Python Send(d1)
''')
#print(d1)
jmp.run_jsl('''
j=Python Get(j);
//b=Python Get(d1);
if(j==1,d2=d1;d2<<setName("test");,current data table(d2);d2<<Concatenate(Data Table(d1),Append to first table);Close(d1,nosave));
''')I still don't have an answer.Looking forward to expert help.
I asked ChatGPT several times, and python's asyncio framework is written like this
But the execution is always unsuccessful.
Ask for expert help in your community.
Thanks!
import asyncio
import concurrent.futures
import jmp
# Define a global variable kk
kk = 1
# Create an asynchronous function to run the JSL script
async def run_jsl_script():
global kk
loop = asyncio.get_event_loop()
# Simplified JSL script
jsl_script = f'''
Print("Value of kk: {kk}");
b = Python Get({kk});
Print("Value of b: ", b);
d1 = New Table("o", Add Rows(1), New Column("date", Set Values({{b}})));
if (b == 1,
d2 = d1;
d2 << Set Name("Name 2");
Print("Table d1 copied to d2 with new name.");
,
current data table(d2);
d2 << Concatenate(Data Table(d1), Append to first table);
Close(d1, nosave);
);
Python Send(d1);
'''
# Print the JSL script content for debugging
print("JSL script to be executed:")
print(jsl_script)
try:
# Use a thread pool to run the synchronous JSL script
with concurrent.futures.ThreadPoolExecutor() as pool:
# Call jmp.run_jsl function
await loop.run_in_executor(pool, lambda: jmp.run_jsl(jsl_script))
except Exception as e:
print(f"Error occurred: {e}")
# Update the kk variable
kk += 1
print(f"Current value of kk: {kk}")
# Main asynchronous function
async def main():
# Example of running the JSL script multiple times
for _ in range(3): # For example, run three times
await run_jsl_script()
print("All JSL scripts executed.")
# Run the main function
if __name__ == "__main__":
asyncio.run(main())
Google search: Python base36
gives the following for base36 conversion including a 2-line solution using numpy.
https://stackoverflow.com/questions/1181919/python-base-36-encoding
One of many search results for Python and base36.
Also understand that Python's Epoch date is 1 Jan 1970. If you are getting JMP's raw date value the Epoch date is 1 Jan 1904. Also, when doing direct time conversions on the seconds, make sure you also account for leap years.