The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 need variable resolution for data but "sort" doesn't cooperate too well
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

salzberg

Columbus, OH, USA
8 Posts

Posted - 12/31/1998 :  7:45:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

This is my problem:
I'm entering data that has one X column and multiple Y's. For some of the Y's I'd like to increase the resolution of the data(having X's with variable spacing) without needing to introduce a new X column for each one.
The way I do this is by introducing the new X-values at the bottom of the X-column list, while doing the same for those Y columns whose resolution I'm interested in increasing, and then selecting all columns (one X, all of the Y's) to perfrom a "Sort" using the values of X. What bothers me is that if there are repeat X items, instead of deleting them, the X's are retained, in repeated form (if I have 20 identical values for X, all of them will be in the same X column, while the respective Y values will be blank for some Y columns and filled for other Y's, making further processing a headache.
How can I get rid of the "empty" Y values and the repeat X values in my whole worksheet? I know this is a pain but I've run into this problem many times.

Thanks,

Aldo Salzberg

Gary Lane

USA
150 Posts

Posted - 01/05/1999 :  7:11:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I believe the following script will accomplish your goal...please verify its functionality before permanently altering your data. To remove unwanted rows, first sort your worksheet in ascending order by the X dataset. Then, copy paste the script to the Script Window (select Window:Script Window to open the Script Window), highlight the entire script, and press the ENTER key to run it.

The script deletes all rows that contain duplicate X values and at least one missing Y value. If this is not exactly what you want, please feel free to modify the script as needed.


//////////////////////////////////////////////////////////////////////
// Script Name: DelDupXRows
//////////////////////////////////////////////////////////////////////
/*
Description:

The script DelDupXRows deletes all rows in a worksheet that contain
duplicate X values and that have at least one missing value in the row.


Assumptions: 1) The active window is a worksheet window that contains
at least one X dataset and one Y dataset. The X
dataset must be column 1.
2) The worksheet is sorted on the X values in ascending
order.


Arguments: None.


Code:
*/

get col(1) -e nrows; // Get nrows in X column
ncols=wks.ncols; // Get ncols in worksheet
kk=0; // Init delrow array index
create delrow -n nrows/2; // Create delrow array
loop(ii,1,nrows) { /* Loop on nrows in X column */
// If X value is a duplicate of previous or subsequent row then...
if((col(1)[ii]==col(1)[ii-1]) | | (col(1)[ii]==col(1)[ii+1])) {
loop(jj,2,ncols) { /* Loop on columns for the row */
if(col($(jj))[$(ii)]==(0/0)) {/* If row contains missing value */
kk+=1; // Increment index for delrow
delrow[kk]=ii; // Save row num to delete
break; // Break out of innermost loop
};
};
};
};
for(ii=kk;ii>0;ii--) { /* For each element in delrow loop backwards */
mark -d %(%H,1) -b delrow[ii] -e delrow[ii]; // Delete the row
sec -p 0.1; // Wait 0.1 sec for worksheet to update
};
delete delrow; // Delete the delrow array

[This message has been edited by Gary Lane (edited 01-05-99).]

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000