Opened CSV file - how to get path in JSL

Reply
New Contributor
Posts: 2

Opened CSV file - how to get path in JSL

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

Super User
Super User
Posts: 6,502

Re: Opened CSV file - how to get path in JSL

If you are generating the JMP code then why not just write the path into the code that you generate?
New Contributor
Posts: 2

Re: Opened CSV file - how to get path in JSL

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.

Ask a Question
Discussion stats
  • 2 replies
  • 398 views
  • 0 likes
  • 2 in conversation