cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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 );
    );
);
 

Recommended Articles