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
 Splitting worksheet into two sheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

shashank.vasudevan

Germany
4 Posts

Posted - 08/12/2016 :  05:27:07 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I work with RCWA that generates a lot of *.dat files that I process in origin. However, for my current task, i need to split the worksheets into two which I will then process. The worksheets consist of just two columns, one for x axis and one for y axis.

Here is not like just splitting the worksheet from a specific row. For example, the data might look like this:

Col A Col B
1 0
2 10
3 20
4 8
5 0
6 0
7 3
8 15
9 5
10 0
11 0

It is a pattern. It starts from zero, increases to a maximum and decreases to zero for several values and then increases and decreases to zero. However, the range of values for which it is non-zero is not always same. For the above example, zeros appear at row 5. For the next worksheet, it might appear at row 10 and so on. There are several hundreds of rows and several thousands of worksheets.

can someone please help me with splitting the worksheets into two such that one worksheet has values from zero to maximum back to zero. The second worksheet has values from zero to the second set of values and back to zero.
I mean something like:

Worksheet 1
Col A Col B
1 0
2 10
3 20
4 8
5 0

worksheet 2
1 0
2 3
3 15
4 5
5 0
6 0

Thank you.

Regards,
Shashank

Origin Ver. OriginPro 2015G (64-bit) Sr2, b9.2.272 (Lehre)
and Service Release (Select Help-->About Origin):
Operating System:Windows 7 Enterprise, Service Pack 1

JacquelineHe

287 Posts

Posted - 08/15/2016 :  07:11:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There is a simple tool to split the worksheet as your requirement.
I suggest you can try to use the following Labtalk script.
Copy the script into "Script Window" (Window: Script Window), and highlight all script press "Enter" key.

Then will get the result as the image. I assume the dataset in the Book1 sheet1:


get col(A) -e numpoints; // get the number of the row
aa=1;
for(ii=1; ii<=numpoints; ii++)  
{
jj=ii+1;
if (Col(B)[ii]==0 && Col(B)[jj]==0)
{
wrcopy iw:=[book1]sheet1! r1:=aa r2:=ii ow:=<new>;
aa=jj;
}
page.active = 1;
}





Thanks
Jacqueline
Originlab

Edited by - JacquelineHe on 08/15/2016 07:13:31 AM
Go to Top of Page

JacquelineHe

287 Posts

Posted - 08/15/2016 :  07:25:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you want to set the new sheet Column 1 filling with row number, you can add a script (csetvalue formula:="i" col:=1; ) to the above script:


get col(A) -e numpoints; // get number of the row in the dataset
aa=1;

//loop script with decision structures
for(ii=1; ii<=numpoints; ii++)  
{
jj=ii+1;
if (Col(B)[ii]==0 && Col(B)[jj]==0)
{
wrcopy iw:=[book1]sheet1! r1:=aa r2:=ii ow:=<new>;
csetvalue formula:="i" col:=1; //Fill the column 1 with row number
aa=jj;
}
page.active = 1;
}



Thanks
Jacqueline
OriginLab

Edited by - JacquelineHe on 08/15/2016 07:27:11 AM
Go to Top of Page

shashank.vasudevan

Germany
4 Posts

Posted - 08/22/2016 :  10:54:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey Jacqueline,

That is awesome. Thank you very much.

Have a great day ahead :)

Best,
Shashank
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