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 for Programming
 LabTalk Forum
 Selecting non-masked rows in a range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

thiago.maf

22 Posts

Posted - 06/12/2009 :  2:12:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0 SR5
Operating System: Windows 7

Hi everybody,

I have worksheets with four columns.
I want to export all data that is not masked. Something like that:

* Set the active worsheet as a range;
* Exclude masked rows from this range;
* Save range to a file.

I'm in trouble to remove masked rows from my range. Anyone know anhything about it? I can't find any in Wiki or in this board? Did I miss something?

Thanks

thiago.maf

22 Posts

Posted - 06/12/2009 :  3:37:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi...

Sorry, I've found something here (http://www.originlab.com/forum/topic.asp?TOPIC_ID=3453) that could help me.
It's a bit different from what I've told here, but...

Here's my code:

// Get number of rows in current sheet
irows = wks.maxrows;
// Save name of current sheet in %a variable
%a=%h;
// Create a new sheet
win -t;
// Initialize counter
inum = 1;
// Loop over all rows of source sheet
for(ii=1; ii<=irows; ii++)
{
// If cell in 1st col is masked...
if( 1 != ismasked(ii, %(%a,1)) )
{
for (jj=1; jj<=wks.nCols; jj++) {
// Copy over to destiation
%(%h,jj,inum) = %(%a,jj,ii);
}

// Update counter
inum++;
}
wks.export.cntrl = 2;
save -wh %h "D:\Unicamp\Biofótons\Dados\1s08\Dados\Série T\Coordenadas\teste.txt";
win -c %h;
}

The last line (win -c %h) was supposed to close and del the created (temp) Workbook. But it close and del every workbook in the folder.
Plus, I've this error message: Error: "%
LabTalk expression error: 2"
Go to Top of Page

thiago.maf

22 Posts

Posted - 06/12/2009 :  3:51:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is the working code.

Thanks and sorry for the odd topic.

// Get number of rows in current sheet
irows = wks.maxrows;
// Save name of current sheet in %a variable
%a=%h;
// Create a new sheet
win -t;
%z = %h;
// Initialize counter
inum = 1;
// Loop over all rows of source sheet
for(ii=1; ii<=irows; ii++)
{
// If cell in 1st col is masked...
if( 1 != ismasked(ii, %(%a,1)) )
{
for (jj=1; jj<=wks.nCols; jj++) {
// Copy over to destiation
%(%h,jj,inum) = %(%a,jj,ii);
}

// Update counter
inum++;
}
}
wks.export.cntrl = 2;
save -wh %h %1;

win -c %h;
Go to Top of Page

thiago.maf

22 Posts

Posted - 06/12/2009 :  3:56:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dudes.... this isn't a good way for me.

My worksheet is too big for this method, it's too much slow.

Anyone know another method, via range, that I have not to check every row?
How can I use FindMasks?

Thanks
Go to Top of Page

greg

USA
1379 Posts

Posted - 06/12/2009 :  4:11:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Assuming you want to maintain row integrity (i.e. you really have masked all column cells in any given row), then you need only examine one column and the whole thing can be done in three lines:

wxt test:="col(A)<i>==0" ow:=[<input>]<new name:=TempForExport>;
expasc iw:=TempForExport path:="D:\MyData.dat" short:=0 long:=0 unit:=0 comment:=0;
layer -d;
Go to Top of Page

thiago.maf

22 Posts

Posted - 06/12/2009 :  4:32:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
MUCH BETTER! Work well!

Can I ask some?
How can I save files in *.txt format?

http://www.originlab.com/www/helponline/origin8/en/X-Function/X-Function.htm#X-Function/expASC.html
This doesn't help.... =/

THANKS! A LOT!
Go to Top of Page

greg

USA
1379 Posts

Posted - 06/12/2009 :  4:39:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
wxt test:="col(A)<i>==0" ow:=[<input>]<new name:=TempForExport>;
expasc iw:=TempForExport type:=1 path:="D:\MyData.txt" short:=0 long:=0 unit:=0 comment:=0;
layer -d;
Go to Top of Page

thiago.maf

22 Posts

Posted - 06/12/2009 :  4:43:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Nope.... doesn't work.
I've tried this.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/13/2009 :  10:12:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried with some simple data and setting some cells in col(A) as missing values and it worked for me, so can you give some details on how it didnt work for you?

CP
Go to Top of Page

thiago.maf

22 Posts

Posted - 06/13/2009 :  10:15:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It work fine, but simply don't export in txt mode.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/14/2009 :  9:17:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
When I tried, I saw txt file created, so you need to give some details on how you saw failure.

Can you try writing to a different location? as there might be limitation of creating TXT file on that D: root path? Can yuo try like putting it to

c:\test\myfile.txt


CP
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