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
 Forum for Origin C
 set -er in OC?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mike Buess

USA
3037 Posts

Posted - 03/06/2003 :  08:20:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I need to increase the number of rows in my dataset (worksheet) without assigning values to its elements. Origin C resizing methods I've tried so far (SetSize and SetUpperBound) set the cell values to 0/0. I need a method that acts like this LabTalk command...

set dataset -er nrows;

Suggestions?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/06/2003 08:21:55 AM

Gary Lane

USA
150 Posts

Posted - 03/06/2003 :  12:32:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Worksheet class inherits GetNumRows from Datasheet class but there is no SetNumRows. I think we will be adding Get/SetNumRows to column class and I will ask for SetNumRows for Datasheet/Worksheet as well. So I guess for now you will need to use LT_execute.

Gary

Edited by - Gary Lane on 03/06/2003 12:49:18 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/06/2003 :  1:25:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Gary,

I think SetNumRows would be what I want, but it doesn't seem to exist. (I see you already answered that.) I need to increase the number of rows in a dataset or worksheet without inserting any values (numbers or 0/0).

I'm using Append to import a data file in blocks and have discovered that the operation is nearly 10x faster if the dataset I'm appending to does not have to grow with each append. (That is, if all of the necessary rows already exist but are empty.) So far the only way I've been able to do that is to create a worksheet, set the number of rows with LT_execute("set %H -er nrows") and append to one of its columns. I'd like to use a temporary dataset with nrows empty rows instead, but I can't seem to do that in Origin C. There are several ways to create a dataset with the correct size, but they all fill it with numbers (0) or nulls (0/0). Then the operation takes even longer and the dataset ends up twice as large as it needs to be.

So how can I create an empty dataset of a given size in Origin C?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/06/2003 1:29:25 PM
Go to Top of Page

Gary Lane

USA
150 Posts

Posted - 03/06/2003 :  3:15:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Currently I think LT_execute("set %H -er nrows") is the only way to do this but as I said we are hoping to add SetNumRows to Column class and maybe even Worksheet class which should do this for you. We are working on this now and hopefully it will be done for SR4 due out relatively soon.

I have one other idea. Try Dataset::SetSize followed by Dataset::SetUpperBound like below:

Dataset ds("Data1_A");
ds.SetSize(50); // Total rows 0 to 49
ds.SetUpperBound(24); // O based offset

Rows 25 to 49 will exist in the worksheet but no values (either 0 or 0/0) are displayed in those rows of the worksheet.

Gary





Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/06/2003 :  3:45:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, Gary... sounds good. I'll try it this evening.

Mike Buess
Origin WebRing Member
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/06/2003 :  8:02:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Gary,

Your suggestion worked perfectly.

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( blockLength*blockCount );
dd.SetUpperBound( 0 );
- append blockCount blocks of size blockLength to dd -
- do something with dd -
Execution time: 2.6s

Compared to this...

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( 0 );
- append blockCount blocks of size blockLength to dd -
- do same thing with dd -
Execution time: 31.4s

End results are identical. Many thanks!

Mike Buess
Origin WebRing Member
Go to Top of Page

Gary Lane

USA
150 Posts

Posted - 03/07/2003 :  08:15:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Wow!

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/07/2003 :  10:30:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Just to tie up loose ends...

The fast and slow methods did not produce the exact same results. dd.SetUpperBound(0) leaves NaN in the first row of dd, so its final data are off by one row. That's easily taken care of with dd.TrimLeft().

long blockLength = 2048;
long blockCount = 1024;
Dataset dd;
dd.Create( blockLength*blockCount+1 );
dd.SetUpperBound( 0 );
- append blockCount blocks of size blockLength to dd -
dd.TrimLeft();
- do something with dd -

Mike Buess
Origin WebRing Member
Go to Top of Page

Gary Lane

USA
150 Posts

Posted - 03/07/2003 :  11:27:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Try

Dataset ds("Data1_A");
ds.SetSize(50);
ds.SetUpperBound(-1);
vector vv = {1,2,3,4,5,6,7,8,9};
ds.Append(vv,REDRAW_REFRESH);

ds.SetUpperBound(-1); will display no rows while SetUpperBound(0) says display value in first row (0 based offset). I will make sure this is better documented for future.

BTW: It looks like Worksheet class and Column class SetNumRows() will make it into SR4.

Thanks for your persistence.

-Gary

Edited by - Gary Lane on 03/07/2003 12:15:27 PM
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