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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Insert multiple Rows between each row and fill

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
gkbradshaw Posted - 05/15/2011 : 1:35:16 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
AmandaLu Posted - 05/16/2011 : 04:49:52 AM
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)

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000