cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are aware of an issue causing intermittent login problems for some users following a recent update. Learn More

Translate the entire conversation x

Reading from an Excel File, MP10

SFares
14-Alexandrite

Reading from an Excel File, MP10

Hello,

 

I am reading values from an Excel sheet. I was building on the answer that Werner had for one of the questions. I have attached both P10 sheet and the excel sheet i am reading from. I was able to read the values for some but not others. The problem is there are dashes at TPP3,TPP5,... 

SFares_0-1756498602597.png

SFares_1-1756498843852.png

 

Thanks,

Sam

 

 

ACCEPTED SOLUTION

Accepted Solutions

For example, you could do something like the following, Sam.

 

2025 08 29 A.png

 

Stuart

View solution in original post

8 REPLIES 8
StuartBruff
23-Emerald IV
(To:SFares)

The reason you are getting the error is that you are multiplying the dashes by a unit (in.lbf), and Mathcad raises an error when multiplying a scalar by a string..

 

How do you want to handle the dashes within the rest of your worksheet?  Eg, convert them to zero or NaN.

 

Stuart

SFares
14-Alexandrite
(To:StuartBruff)

Hi Stuart,

 

Is it possible to read the excel sheet by skipping the row with dashes

by specifying certain cells like F13:F14, F16:17,.. that corresponds to:

SFares_0-1756501442146.png

 

Regards,

Sam

StuartBruff
23-Emerald IV
(To:SFares)

Hi Sam,

 

Yes, it's possible to skip rows, but what values do you want to put in the TCn variables in their place?

 

Stuart

For example, you could do something like the following, Sam.

 

2025 08 29 A.png

 

Stuart

SFares
14-Alexandrite
(To:StuartBruff)

I appreciate it. Thanks a lot Stuart!

 

Sam

StuartBruff
23-Emerald IV
(To:SFares)

No worries, Sam.

 

Stuart

Werner_E
25-Diamond I
(To:SFares)

Just a side note. 

When you replace non-scalar values by NaN's, you can add the appropriate unit as Prime allows adding units to NaN. "IsNaN" still works OK if you later need to check if a variable was replaced by an NaN or has a numeric value:

Werner_E_2-1756506983472.png

 

You may also read, replace strings and add units in one go, however, readability suffers as a result.

Werner_E_1-1756506819746.png

 

 

Doh!

 

This is what comes of changing one's mind whilst typing.  There is no need for the input parameter repval, as it isn't used. The replace function simply replaces any non-scalar value with newval.   However, a more general replace function might prove useful, which uses the repval as an input argument, so here are two versions of replace, side by side. 

 

2025 08 29 B.png

 

Stuart

Announcements


Top Tags