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
 Splitting rows into multiple columns

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
j.miao Posted - 07/24/2014 : 09:10:22 AM
Hello everyone,

I have a data with two columns, i.e. column (1), column (2).

I want to separate the columns, meaning that Origin is supposed to copy the first 150 data points from columns (1, 2) to columns (3, 4), and the second 150 data points from columns (1, 2) to columns (5, 6), and so on…

However, I have 1500 rows, or 10 columns with 150 data points each, so writing a script like that will take considerable time. (or even more rows)

So my question is: How can I write a kind of loop for that function which would also make it easy to change the number of points?

I use OriginPro 8.5.1.


Thanks in advance for any help!
07/24/2014

JUN
5   L A T E S T    R E P L I E S    (Newest First)
j.miao Posted - 07/24/2014 : 12:13:18 PM
Great!

That is what I want!

Thanks a lot!


quote:
Originally posted by lkb0221

Hi,

Please try the following script, change the variable WinSize (3rd line) for different intervals

// Start
range r1 = 1; // Col(1)
range r2 = 2; // Col(2)
int WinSize = 150; // Window size
int Num = (wks.nrows / WinSize) + 1; // +1 for extra data in case
for (int ii = 1; ii <= Num; ii++)
{
range d1 = $(2*ii+1);
range d2 = $(2*ii+2);
copydata irng:=r1[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d1;
copydata irng:=r2[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d2;
wks.col$(2*ii+1).type = 4; // Set column be X
wks.col$(2*ii+2).type = 1; // Set column be Y
}
// End



Zheng
OriginLab



JUN
lkb0221 Posted - 07/24/2014 : 11:42:16 AM
Hi,

Please try the following script, change the variable WinSize (3rd line) for different intervals

// Start
range r1 = 1; // Col(1)
range r2 = 2; // Col(2)
int WinSize = 150; // Window size
int Num = (wks.nrows / WinSize) + 1; // +1 for extra data in case
for (int ii = 1; ii <= Num; ii++)
{
range d1 = $(2*ii+1);
range d2 = $(2*ii+2);
copydata irng:=r1[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d1;
copydata irng:=r2[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d2;
wks.col$(2*ii+1).type = 4; // Set column be X
wks.col$(2*ii+2).type = 1; // Set column be Y
}
// End



Zheng
OriginLab
j.miao Posted - 07/24/2014 : 11:28:23 AM
Moreover,

If the interval was 200 (or 250) instead of 150, how could I do with that?

Thanks again!


quote:
Originally posted by lkb0221

Hi,

The following script will only copy numeric data over.
//
range r1 = 1; // Col(1)
range r2 = 2; // Col(2)
int Num = (wks.nrows / 150) + 1; // +1 for extra data
for (int ii = 1; ii <= Num; ii++)
{
range d1 = $(2*ii+1);
range d2 = $(2*ii+2);
copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1;
copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2;
}
//


Zheng
OriginLab



JUN
j.miao Posted - 07/24/2014 : 11:19:32 AM
Thanks a lots for your help. It works well and make a good shape.

However, the columns cannot be set to be X and Y, respectively.
meaning, col(3)-X ; col(4)-Y; col(5)-X ; col(6)-Y; col(7)-X ; col(8)-Y; and so on.

Could you give a suggestion or improve that script?

Thanks again!

quote:
Originally posted by lkb0221

Hi,

The following script will only copy numeric data over.
//
range r1 = 1; // Col(1)
range r2 = 2; // Col(2)
int Num = (wks.nrows / 150) + 1; // +1 for extra data
for (int ii = 1; ii <= Num; ii++)
{
range d1 = $(2*ii+1);
range d2 = $(2*ii+2);
copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1;
copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2;
}
//


Zheng
OriginLab



JUN
lkb0221 Posted - 07/24/2014 : 10:54:34 AM
Hi,

The following script will only copy numeric data over.
//
range r1 = 1; // Col(1)
range r2 = 2; // Col(2)
int Num = (wks.nrows / 150) + 1; // +1 for extra data
for (int ii = 1; ii <= Num; ii++)
{
range d1 = $(2*ii+1);
range d2 = $(2*ii+2);
copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1;
copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2;
}
//


Zheng
OriginLab

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