I have a folder with 365 .csv-files. I want to convert each .csv-file into a .jmp-file and delete some columns in the .jmp-file, then save the .jmp-file with the name of the .csv-file and exit JMP. All this has to be done automatically with a JSL-Script.
I already have a batch-script, which starts a JSL-Script and hands one .csv-file to the JSL-Script. The JSL-Script then opens the .csv-file and deletes the columns i want to delete.
I have a problem, when it comes to saving the .jmp-file and quitting JMP with the JSL-Script in order for the batch-script to start with the next .csv-file to open with the JSL-Script.
The .jmp-file won't save and therefor JMP doesn't quit, so that my whole batch-process stops, because my batch-script waits for JMP to be closed.
I open the .csv-files according to the response of user "twaintwist" at the bottom of this discussion: Passing Parameters to JSL script
All my .csv-files + the batch-script + the .jsl-script are in the same folder.
This solution works fine for me, so here is my batch-script:
for %%f in (*.csv) do (
echo fileName = "%%~nf.csv";>file.txt
copy /y /b file.txt+myScript.jsl temp.jsl
JMP temp.jsl
timeout / t 5
del %%~nf.csv
timeout / t 5
del file.txt
timeout / t 5
del temp.jsl
)
pause
My JSL-Script then opens the .csv-file handed over by the .bat-script, and deletes some columns. But after deleting the cloumns it seems like my JSL-Script just stops.
The .jmp-file won't save and JMP does not quit. As you can see in the Script I tried different methods to save and close the window with JSL.
So here is my JSL-Script:
doc = Open(fileName);
dt = Current Data Table();
// Turns off display updating to allow for quick updating of a data table.
dt << Begin Data Update;
ColList = {
//#COLUMNS TO BE DELETED#
};
dt << Delete Columns(ColList);
dt << End Data Update;
nameLength = Length(fileName);
fielName = Left(fileName, nameLength - 3);
Name = fileName || "jmp";
dt<<save("C:\Users\MartinSchmid\Desktop\jsl_batch\" || Name);
doc<<save("C:\Users\MartinSchmid\Desktop\jsl_batch\" || Name);
wait(10);
Close (dt, nosave);
Close (doc, NoSave);
//doc << close window;
//dt<<close window();
//Close All(Data Tables, save(fileName+"jmp"));
Exit(nosave);
Quit(nosave);