01-06-2015 03:15 AM - edited 01-06-2015 03:22 AM
Hello,
I am trying to read a text file containing string and numbers...Then I would like to perform some statistic calclulation of numbers....
The text file is some thing like this:
Date Time Status Speed(rpm) Time (ms)
20122014 1515 OK 1250 250
20122014 1516 NOK 1261 -
I succesfully read the text file using "Read from Text file Function".
However, in the third line, since the value of time is "-", my fucntion read it az Zero !! Do you know why?
This cause an error in my statistic calculation.
Do you know how can I get rid of this "-" in my reading?
Thanks alot,
01-06-2015 03:34 AM - edited 01-06-2015 03:38 AM
You will need to handle this case yourself and think about what you want to happen with those data points. I think doing a string replace before the spreadsheet string to array function might work. If you replaced the "-" with "NaN", LabVIEW will use the DBL Not A Number instead of 0. I'm not sure if the statistical functions will ignore NaN's in their calculations though but at least you could filter out the NaN's before doing the calculations instead of potentially having 0's from dashes and actual 0's as data points.
The reason it does this is because 0 is the default data type for a DBL and it's not possible to convert a "-" to a number so it uses the default value.
This should work:
01-06-2015 07:10 AM
Be careful about just arbitrarily replacing "-" with "NaN" in the initial string. You could be messing up some legitamite negative numbers. You might just want to use the Spreadsheet String To Array to convert into a string array and then replacing before converting into a number.
01-06-2015 09:29 AM
01-06-2015 11:58 AM
Thank you very much.
I used your method and it worked.
Many thanks and bests regards.