cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Katz0801
Level II

Deleting Duplicate Scripts

Hello,

I have concatenated multiple files into a database which has lead to a database with many duplicated scripts. Is there a way to write a script to remove duplicated scripts? I don't want to delete them manually as I will add more files to the database with concatenation in the future which would again add the scripts to the file.

1 ACCEPTED SOLUTION

Accepted Solutions
Katz0801
Level II

Re: Deleting Duplicate Scripts

Update - I solved it using this method:

dt = Current Data Table(); 
names = dt << Get Table Script Names;

Show(names);
wordsToDelete = {"Script 1 name", "Script 2 name", "Script 3 name"};
For(i = 1, i <= N Items(names), i++,
    scriptName = names[i];
    containsWord = 0;
    For(j = 1, j <= N Items(wordsToDelete), j++,
        word = wordsToDelete[j];
        If( Contains( scriptName, word ),
            containsWord = 1;
            Break();
        );
    );
   If( containsWord,
        dt << Delete Scripts( scriptName );
    );
);
 

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Deleting Duplicate Scripts

You can use Get Table Script Names to get names of all table scripts. Then you can filter that down to a list of scripts you wish to remove and finally delete them with << Delete Scripts

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
names = dt << Get Table Script Names;
Show(names);
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Table Script(
	"New Script",
	Distribution(Column(:Height, :Weight), By(:sex))
);
Wait(2);
dt << Delete Scripts("New Script");
-Jarmo
Katz0801
Level II

Re: Deleting Duplicate Scripts

Update - I solved it using this method:

dt = Current Data Table(); 
names = dt << Get Table Script Names;

Show(names);
wordsToDelete = {"Script 1 name", "Script 2 name", "Script 3 name"};
For(i = 1, i <= N Items(names), i++,
    scriptName = names[i];
    containsWord = 0;
    For(j = 1, j <= N Items(wordsToDelete), j++,
        word = wordsToDelete[j];
        If( Contains( scriptName, word ),
            containsWord = 1;
            Break();
        );
    );
   If( containsWord,
        dt << Delete Scripts( scriptName );
    );
);