Author |
Topic  |
|
hawu001
5 Posts |
Posted - 10/09/2018 : 4:04:39 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): b9.5.1.195 Operating System:Win10
Hi fellas,
I'm relatively new in this field and I was actually excited by using the LabTalk-Script, cuz it could really save a lot of time sometimes.
But there's just a new problem: every time I run the code, it ends up with a crash of the programme.
Description of my task at first:
I have 4 columns of Data: let's say A, B, C, D. Col(C) is for the measured data, and Col(B) is the "time interval" of the measured Data, which is very small (like 0, 0.2, 0.4, 0.6,..., 10000) and therefore has a lot of rows. The Col(A) is another "time interval" which is in comparision with Col(B) very wide(like 0, 100, 200, 300,..., 10000) and therefore has less rows.
What I need is to select the value of Col(C) (measured data) after the wider time interval and paste it into Col(D).I.e. when the value of Col(B) is found in Col(A), the value in the same row of Col(C) should be copied and pasted into Col(D).
The script is pasted as following: ========================================================== for( i=1,j=1 ; i<=40 && j <=80 ; j++ ) { range rr=Col(D)[$(i)]; aa=Col(A)[$(i)]; bb=Col(B)[$(j)]; cc=Col(C)[$(j)]; if($(bb)==$(aa)) {rr=$(cc); rr[1]=; i++; } else {continue; } } ========================================================== When i and j are less than 80, it seems actually good. The goal can be reached. But since I have really a lot of rows of data (more than 300k), the code will be collapsed at about 10k...
My question is, if anyone has the same experience? Can I make the LabTalk-Script somehow more efficient?
My Laptop has i7 CPU, 8G memory, HDD. But obviously I wouldn't buy a new one only for solving this problem.
Thanks a lot in advance to the community!
Best regards Howie
LabTalk ist eine Quälerei. --- J. S. Bach |
|
yuki_wu
896 Posts |
|
hawu001
5 Posts |
Posted - 10/10/2018 : 06:53:51 AM
|
Hi Yuki,
thanks for your hints, but in the if sentence, I have to compare two columns with different length (40 and 80, as shown in the graph).
That's also why I used i and j.
Would wxt still work?
quote: Originally posted by yuki_wu
Hi Howie,
Using wxt X-Function (menu: Worksheet: Worksheet Query) will be faster: wxt test:="col(A)==col(B)" ow:=<new>;
https://www.originlab.com/doc/X-Function/ref/wxt https://www.originlab.com/doc/Origin-Help/Wks-Query
Hope it helps.
Regards, Yuki OriginLab
LabTalk ist eine Quälerei. --- J. S. Bach |
 |
|
hawu001
5 Posts |
|
hawu001
5 Posts |
|
cpyang
USA
1406 Posts |
Posted - 10/10/2018 : 9:21:54 PM
|
Just put column formula into col(D) as
table(B,C,A)

Most things can be done with column formula and then you just save the book as template, and write only the smallest amount of code.
CP
CP
|
 |
|
hawu001
5 Posts |
Posted - 10/30/2018 : 06:41:42 AM
|
Hi CP,
thank you a lot!! It's really much easier and more effectiver!
Best Regards, Howie
quote: Originally posted by cpyang
Just put column formula into col(D) as
table(B,C,A)

Most things can be done with column formula and then you just save the book as template, and write only the smallest amount of code.
CP
CP
LabTalk ist eine Quälerei. --- J. S. Bach |
 |
|
|
Topic  |
|
|
|