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
shasheminassab
Level IV

How to delete X number of rows from end of each table before concatenating them?

I have a large number of CSV files (with same columns but different number of rows) in a folder and would like to concatenate them all. However, I need to delete 5 rows from end of each table before concatenating them. I would appreciate any help with writing the appropriate JSL code to do this job.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to delete X number of rows from end of each table before concatenating them?

Here is a simple script that will concatenate all open data tables after deleting the last 5 rows in each table.

Names Default To Here( 1 );

tableList = {};

For( i = 1, i <= N Table(), i++,
	Data Table( i ) << delete rows(
		Index( N Rows( Data Table( i ) ) - 4, N Rows( Data Table( i ) ) )
	);
	Insert Into( tableList, Data Table( i ) << get name );
);

dt = New Table( "All Tables" );

For( i = 1, i <= N Items( tableList ), i++,
	dt << concatenate( Data Table( tableList[i] ), append to first table( 1 ) )
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How to delete X number of rows from end of each table before concatenating them?

Here is a simple script that will concatenate all open data tables after deleting the last 5 rows in each table.

Names Default To Here( 1 );

tableList = {};

For( i = 1, i <= N Table(), i++,
	Data Table( i ) << delete rows(
		Index( N Rows( Data Table( i ) ) - 4, N Rows( Data Table( i ) ) )
	);
	Insert Into( tableList, Data Table( i ) << get name );
);

dt = New Table( "All Tables" );

For( i = 1, i <= N Items( tableList ), i++,
	dt << concatenate( Data Table( tableList[i] ), append to first table( 1 ) )
);
Jim
shasheminassab
Level IV

Re: How to delete X number of rows from end of each table before concatenating them?

Thanks a lot Jim!!!

Recommended Articles