BookmarkSubscribeRSS Feed
wooden
Calcite | Level 5

At work, I've written some Python scripts to pull a bunch of data from our database, save it as a CSV, open it in JMP, and run a JSL script on it to create some graphs and other junk. The problem I'm running into is that I cannot find a way to get the full path to the CSV file within the JSL script.

 

The Python script creates the directory, moves the CSV into it, and then opens the CSV in JMP and immediately runs the JSL script on it. In th Python script, this looks something like:

os.chdir(sJMPLoc) // move to the JMP install dir
subprocess.Popen(sCmdOpen) // execute the command to open the CSV file in JMP
subprocess.Popen(sCmdScript) // execute the command to run the JSL script

 

In the JSL:

dt = Current Data Table();

dt << Save();

 

This didn't appear to work, so I started digging to see where it thought the file was stored and added this to my script:
dir = dt << getpath;
show(dir);

 

Results of that:

dir = "POWER_CORRELATIONS_YESTERDAY_09_08_15__15_36_57.jmp";

Turns out JMP is converting the .CSV into a .JMP file and storing it in some temp directory, or at least the dt << getpath function isn't aware of the original path.

 

How can I get the path to the CSV where the CSV was when it was opened

 

Thanks,

Chip

2 REPLIES 2
Tom
Super User Tom
Super User
If you are generating the JMP code then why not just write the path into the code that you generate?
wooden
Calcite | Level 5

Every time the Python script runs, it creates a new directory for the data and all reports for it. If I could get our database tools to save the file as a JMP file, this would all be easy as JMP retains the path to JMP files:

 

/*:
//:*/
dt = Current Data Table();
show(dt << getpath);
/*:

dt << getpath = "C:\Users\cpwood\Documents\correlationData\power_54W_ww32p1_working.jmp";

 

The same cannot be said about CSVs:

/*:
//:*/
dt = Current Data Table();
show(dt << getpath);
/*:

dt << getpath = "POWER_CORRELATIONS_YESTERDAY_09_04_15__15_36_57.jmp";

 

The POWER_CORRELATIONS_YESTERDAY... file was a CSV when opened, but JMP appears to immediately convert it to a JMP file (reasonably so) and ditch the path for some odd reason.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2990 views
  • 0 likes
  • 2 in conversation