| Author |
Topic  |
|
|
parrymi
Finland
Posts |
Posted - 01/17/2006 : 07:43:37 AM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System: XP Hi,
a newbie question about scripting. I would need a simple script to organize my output from an instrument with 1-4 channels. So what i have is n worksheets which are of the type chan1 chan2 chan3 12 34 56 XY XY XY.
What I'd like to do is to extract the Y columns of these worksheets to new worksheets so I'd basically have an X-column which is the same for all the Y's and the Y's from every channel extracted from the output files.
chan1 X Y1 Y2 Y3 Y4 ... Yn
chan2 X Y1 Y2 Y3 Y4 ... Yn etc. that is.
Thanks in advance, Mikko |
|
|
Mike Buess
USA
3037 Posts |
Posted - 01/17/2006 : 4:18:27 PM
|
Hi Mikko,
It shouldn't be hard to combine your data but please describe the problem a little more precisely. You have several XY worksheets for each channel... 12 worksheets for chan1, 34 for chan2, 56 for chan3? How do you distinguish one channel from another? That is, how do you know that worksheet Data1 contains channel 1 (or 2 or 3) data? You must have some way of knowing which worksheets to combine.
Mike Buess Origin WebRing Member |
 |
|
|
parrymi
Finland
Posts |
Posted - 01/18/2006 : 03:55:23 AM
|
Hi, I put my words in a slightly confusing manner. So i've got n worksheets each of which contains data for all channels.
chan1 chan2 chan3 AB CD EF XY XY XY
That is columns a and b contain the data for channel one c and d for 2 etc. All the X columns contain the same values that is wavelength, so they only need to be copied once. So basically I'd like to take the A and B columns from the first worksheet and the b column from the second to the nth column in one worksheet, the C and D columns from the first worksheet and the D columns of the rest of the worksheets in a separate worksheet etc. until I get 4 worksheets with a common X axis and the corresponding Y's.
Hope this clears things a bit. Thanks, Mikko
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 01/18/2006 : 08:10:10 AM
|
Hi Mikko,
This combines all worksheets in the project...
%W=%H; // name of active wks win -t D Origin Channel1; // create channel1 wks win -t D Origin Channel2; // create channel2 wks win -t D Origin Channel3; // create channel3 wks copy %W_A Channel1_A; // copy X col to Channel1 copy %W_C Channel2_A; // copy X col to Channel2 copy %W_E Channel3_A; // copy X col to Channel3 doc -e W // loop through all worksheets { if("%[%H,8]"!="Channel") { copy col(B) Channel1_B; copy col(D) Channel2_B; copy col(F) Channel3_B; }; };
Mike Buess Origin WebRing Member |
 |
|
|
parrymi
Finland
Posts |
Posted - 01/18/2006 : 09:55:09 AM
|
Thanks for the answer! There is however still a problem. The script as is always overwrites col(B) in the Channel windows. I'd like to append the columns to the end of the document and don't seem to know how to 
Cheers, Mikko |
 |
|
|
parrymi
Finland
Posts |
Posted - 01/18/2006 : 1:18:13 PM
|
Hi,
did it finally myself. This is what I came up with:
%W=%H; // name of active wks addcolu=-1; doc -e W { addcolu=addcolu+1; }; win -t D Origin Sample1; // create Sample1 wks worksheet -a addcolu; win -t D Origin Sample2; // create Sample2 wks worksheet -a addcolu; win -t D Origin Sample3; // create Sample3 wks worksheet -a addcolu; copy %W_A Sample1_A; // copy X col to Sample1 copy %W_C Sample2_A; // copy X col to Sample2 copy %W_E Sample3_A; // copy X col to Sample3 coln=2; doc -e W { if("%[%H,7]"!="Sample") { copy col(B) %(Sample1, coln); copy col(D) %(Sample2, coln); copy col(F) %(Sample3, coln); type %h; coln=coln+1; }; };
Thanks for your help!
Mikko |
 |
|
| |
Topic  |
|