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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Cell and missing values

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
peter.cook Posted - 09/18/2003 : 2:42:41 PM
Hi,

I'm scannning a worksheet of numeric data to filter another data set eg

Columns 1 to nCols
Rows 1 to nRows

if %H(Row, Col) < 2 then TestData[Row]=0/0;

Anyway, I used Cell to read all values but this caused problems with missing values so I initially trapped missing values using GetCell and eg

wks.GetCell(Row,Col,strValue);
if (strValue == "--" ) {
// ignore
} else {
wks.Cell(Row,Col,doubleValue);
if (doubleValue < 2 ) {
// record this
};
}

Is there a better way to read off numeric values and yet deal with (trap) missing values?

Cheers,

pete

5   L A T E S T    R E P L I E S    (Newest First)
peter.cook Posted - 10/21/2003 : 08:19:11 AM
Hi CP,

Thanks for reply - will incorporate this, or something similar.

Cheers,

Pete

cpyang Posted - 09/22/2003 : 5:54:05 PM
Peter, you are right,

wks.Cell(Row,Col)

should be able to handle missing value, we will need to fix this.

Trackered as 5219


In the meantime, you can write a separate function to get a cell value, as shown below,



double wks_cell(Worksheet & wks, int nr, int nc)
{
double vv = NANUM;
if(nr < 0 || nr >= wks.GetNumRows() || nc < 0 || nc >= wks.GetNumCols())
return vv;

try {
vv = wks.Cell(nr, nc);
}
catch(int nErr)
{
// put codes here if err handling is needed
}

return vv;
}

void test_check_wks_missing()
{
Worksheet wks = Project.ActiveLayer();

for(int ii = 0; ii < wks.GetNumCols(); ii++)
{
for(int jj = 0; jj < wks.GetNumRows(); jj++)
{
double vv = wks_cell(wks, jj, ii);//wks.Cell(jj, ii);
if(is_missing_value(vv) || vv < 2)
{
string str = wks.TCell(jj, ii);
printf("Cell(%d,%d) is no good, it is \"%s\"\n", jj, ii, str);
}
}
}
}







CP


Edited by - cpyang on 09/22/2003 6:35:11 PM
peter.cook Posted - 09/22/2003 : 07:10:34 AM
THanks,

I might try and adopt this. I guess though Origin should be able to cope with these missing values in a worksheet..!

Cheers,

pete

soapy Posted - 09/21/2003 : 01:34:26 AM
Hi,

Missing values will not cause error in Matrices, so I suggest using matrix for filtering instead of worksheet:

matrix mFilter;
mFilter.CopyFromWks(wks); //Copy the whole worksheet to a matrix

And Then you can use matrix as filter:

if((mFilter[Row][Col]!=NANUM)&&(mFilter[Row][Col]<2))
{
//Action;
}

soapy Posted - 09/21/2003 : 01:34:09 AM
Hi,

Missing values will not cause error in Matrices, so I suggest using matrix for filtering instead of worksheet:

matrix mFilter;
mFilter.CopyFromWks(wks); //Copy the whole worksheet to a matrix

And Then you can use matrix as filter:

if((mFilter[Row][Col]!=NANUM)&&(mFilter[Row][Col]<2))
{
//Action;
}


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000