cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Add a feature to clean data table

What inspired this wish list request? 

Always writing more or less complicated scripts to "clean" my data tables (remove table scripts, table variables, column properties, ...)

 

What is the improvement you would like to see? 

Provide easy platform to cleanup data table. This should give option to remove table scripts, table variables, column properties, row states and all different modifications. In best case user could decide which to remove. Some of these could be implemented to Subset but I feel like this should also be separate platform.

 

Why is this idea important? 

Makes it easier to create new data tables from existing ones without they carrying over non-relevant information.

3 Comments
mia_stephens
Staff
Status changed to: Acknowledged

Interesting idea @jthi . How do you do this today?

jthi
Super User

Depending on the case, I either:

  • Do these manually
  • Script them (if it is automatization)
  • Sometimes I skip the cleaning and might end up with a bit messy data table but it isn't a problem until I share the table

I will most likely write an add-in (I did already start but did come across a "small" feature creep with all sorts of unnecessary features) to perform these specific "metadata" clean-up tasks as I do them quite regularly.

hogi
Level XII

Till the wish gets enough Kudos, this script might help.

It creates a script for the current data table and - depending on the settings, it removes scripts, column properties and the add rows() expression.

 

Names Default To Here( 1 );

removeScripts = 1;
removeColumnProperties = 1;
remove rows = 1;

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << copy table script( "no data" );
tableScript = Eval( Eval Expr( Parse( Expr( Get Clipboard() ) ) ) );

tableScriptList = Substitute( Name Expr( tableScript ), Expr( New Table() ), Expr( List() ) );
If( removeScripts,
	tableScriptList = Filter Each( {part}, tableScriptList, Not( Head( Part ) == Expr( New Script() ) ) )
);
tableScriptList = Transform Each( {part}, tableScriptList,
	If(
		Head( part ) == Expr( New Column() ) & removeColumnProperties,
			Substitute( Name Expr( part ), Extract Expr( part, Set Property( Wild List() ) ), . ),
		Head( part ) == Expr( Add Rows() ) & remove rows, .,
		Name Expr( part )
	)
);
newtableScript = Substitute( Name Expr( tableScriptList ), Expr( List() ), Expr( New Table() ) );

newtableScript;
	

It's far from ideal.

The Substitute is quite dangerous - it does not only replace the expression the user wanted to replace, it replaces all matching expressions!

e.g. any list which remains at the end of the script will be replaced by New Table () !!!

Any new table() which is in a Table Script will be replaced by List() [and then by New table() at the end :]

Do you know any workaround to prevent JMP from doing so?
Substitute Head?

With this issue in mind, I wrote this wish:

🙏 Expression Indexing: read and write access 

One it's available, I will update the script and make it more robust.