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 for Programming
 LabTalk Forum
 Insert multiple Rows between each row and fill
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gkbradshaw

USA
3 Posts

Posted - 05/15/2011 :  1:35:16 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.1 and Service Release 88.89
Operating System: Win XP

I'm trying to figure out a way to insert multiple blank rows in between each row of a current sheet and then fill those blank cells with the appropriate numbers.
For example, if my X column currently has rows of 5, 10, 15, 20, 25, ....etc., then I would like to insert 4 rows in between each of these and fill them with 6, 7, 8, 9....11, 12, 13, 14 and so on to make the X rows increase by one. I also need to fill my y values in a similar manner but these numbers are not sequential so I need to make an interpolation between these points that are currently there (linear interpolation is fine).
Any thoughts? I know I could do this manually but I have found that I need to do this type of manipulation fairly often so writing a script would be very useful. Thanks.

G

AmandaLu

439 Posts

Posted - 05/16/2011 :  04:49:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Most of the LabTalk operations base on columns. So there is no simple way to add/insert rows right now. To do this, you need to transpose the worksheet first, add columns, and then transpose it back.

I wrote an example for you to start. Suppose you have your XY data in Sheet1, Book1. X data is like: 5, 10, 15, 20 Activate Sheet1 and run the following scripts:

nrows=wks.nrows;
wtranspose;
//add columns and fill in values
for(ii=1;ii<nrows;ii++)
{
for(jj=1;jj<=4;jj++)
{
wks.AddCol();
col($(4*(ii--1)+jj+nrows))[1]=$(5*ii+jj);
}
}
wtranspose;    //transpose the worksheet back
//delete the empty columns
ncols=wks.ncols;
range aa=col(3):col($(ncols));
del aa;
sort -w book1 book1_a;     //sort sheet1 in ascending order against col(a)

Edited by - AmandaLu on 05/16/2011 04:53:32 AM
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