Author |
Topic  |
|
chessboard12
10 Posts |
Posted - 01/10/2019 : 09:39:36 AM
|
Origin Ver. and Service Release Origin 2018G (64-bit) Operating System: Windows 10
Hello everyone,
i have a quite big table with 6 columns and approx 25000 rows. The first column contains the time, the 5 next columns display parameters such as temperature,pressure,...etc.
The problem is, that not all datapoints belong to the same test. The first test is about 100 rows long, the second about 250, the third test goes from row 351 to 633 and so on...
it`s just a mess because the results of the tests are not displayed side by side but just among themselves! With all test this adds up to 25000 rows.
Every new "test" in this huge table starts with the letter "H" in the first row.
Now my task was to write a labtalk script which autonomous finds the beginning of a new test via the letter "H" and then cuts out all the six columns and the following rows and pastes it next to the first test.
anyone ideas how to proceed?
i`ve found how to staple and unstaple, or how to move columns of constant size, but nothing similar to my problem.
Ben
|
|
yuki_wu
896 Posts |
Posted - 01/10/2019 : 9:37:29 PM
|
Hi Ben,
You might find something like this:
wks.addCol("Group");
range rA = col(1);
int nRows = rA.GetSize();
range rG = col($(wks.nCols));
int nGroup = 1;
string str$ = "H*";
for(int ii = 1; ii <= nRows; ii++)
{
if(Match(rA[$(ii)]$, str$))
{
nGroup++;
}
rG[$(ii)] = nGroup;
}
wsplit -r 2 mode:=ref ref:=col($(wks.nCols)); Hope it helps.
Regards, Yuki
OriginLab
|
 |
|
chessboard12
10 Posts |
Posted - 01/14/2019 : 06:26:09 AM
|
Hey yuki_wu,
thank you very much for the help!
I am not sure, if it`s impolite to ask for more help, rather than trying to fix this problem on my own, but I`ve never tried programming before and I think starting from scratch would take too long. If you don`t think so, just let me now.
I´ve tried to run your script and it does it`s job- halfways. :) It cuts out sections of the big table and puts it into different origin sheets.
The problem was, that these sections did not go from "H" to "H", but were many rows shorter. This lead to 1000 new sheets with tables approx 25 rows long. I am not sure where the mistake could be. Can you check it again, please?
Maybe I should create a much clearer depiction of my table. It`s like this:
A(X) B(Y) C(Y) D(Y) E(Y) F(Y) G(Y) 1 H Date Time Empty Value1 Value2 Value3 2 D ... ... 0 x1 y1 z1 3 D ... ... 0 x2 y2 z2 4 D ... ... 0 x3 y3 z3 . . ... ... ... ... . . ... . . 102 H Date Time Empty Value1 Value2 Value3 103 D ... ... 0 x101 y101 z101 104 D ... ... 0 x102 y102 z102 . . ... ... ... ... . . . 353 H Date Time Empty Value1 Value2 Value3 354 D ... ... ... ... ... ... . ... H ... ... ... ... ... ... . . . 26749 D ... ... ... ... ... ...
After the transformation all tables should be included in one sheet and look like:
A(X) B(Y) C(Y) D(Y) E(Y) F(Y) G(Y) H(Y) I(Y) J(Y) K(Y) 1 H Date Time Empty Value1 Value2 Value3 Date Time Empty Value1 ... 2 D ... ... 0 x1 y1 z1 ... ... 0 x101 3 D ... ... ... ... ... ... ... ... ... ... 4 . ... ... ... . .
The "empty"- and "date"-columns of course can be deleted. They are not necessary here.
It could be, that this leads to several hundreds of rows, but it doesn`t matter.
Thanks in advance
Ben
|
 |
|
chessboard12
10 Posts |
Posted - 01/22/2019 : 05:40:38 AM
|
quote: Originally posted by yuki_wu
Hi Ben,
You might find something like this:
wks.addCol("Group");
range rA = col(1);
int nRows = rA.GetSize();
range rG = col($(wks.nCols));
int nGroup = 1;
string str$ = "H*";
for(int ii = 1; ii <= nRows; ii++)
{
if(Match(rA[$(ii)]$, str$))
{
nGroup++;
}
rG[$(ii)] = nGroup;
}
wsplit -r 2 mode:=ref ref:=col($(wks.nCols)); Hope it helps.
Regards, Yuki
OriginLab
Hey yuki_wu,
thank you very much for the help!
I am not sure, if it`s impolite to ask for more help, rather than trying to fix this problem on my own, but I`ve never tried programming before and I think starting from scratch would take too long. If you don`t think so, just let me now.
I´ve tried to run your script and it does it`s job- halfways. :) It cuts out sections of the big table and puts it into different origin sheets.
The problem was, that these sections did not go from "H" to "H", but were many rows shorter. This lead to 1000 new sheets with tables approx 25 rows long. I am not sure where the mistake could be. Can you check it again, please?
Maybe I should create a much clearer depiction of my table. It`s like this:
A(X) B(Y) C(Y) D(Y) E(Y) F(Y) G(Y)
1 H Date Time Empty Value1 Value2 Value3 2 D ... ... 0 x1 y1 z1 3 D ... ... 0 x2 y2 z2 4 D ... ... 0 x3 y3 z3 . . ... ... ... ... . . ... . . 102 H Date Time Empty Value1 Value2 Value3 103 D ... ... 0 x101 y101 z101 104 D ... ... 0 x102 y102 z102 . . ... ... ... ... . . . 353 H Date Time Empty Value1 Value2 Value3 354 D ... ... ... ... ... ... . ... H ... ... ... ... ... ... . . . 26749 D ... ... ... ... ... ...
After the transformation all tables should be included in one sheet and look like:
A(X) B(Y) C(Y) D(Y) E(Y) F(Y) G(Y) H(Y) I(Y) J(Y) K(Y) 1 H Date Time Empty Value1 Value2 Value3 Date Time Empty Value1 ... 2 D ... ... 0 x1 y1 z1 ... ... 0 x101 3 D ... ... ... ... ... ... ... ... ... ... 4 . ... ... ... . .
The "empty"- and "date"-columns of course can be deleted. They are not necessary here.
It could be, that this leads to several hundreds of rows, but it doesn`t matter.
Thanks in advance
Ben |
 |
|
|
Topic  |
|
|
|