08-12-2019 11:13 AM
Hi everyone,
I guess the subject is a little misleading, but I could not think of anything else to put in the subject box. I have an excel file that contains both string and number. So for example, the file looks like
Name age
x 10
I managed to read the file from labview, and because I know that age is a number, I can convert that to a number from string. But my question is, what if I do not know that age is a number or if there is another column that contains some other information but I do not know whether it is string or number, how do I determine the type from labview?
I am using labview 8.0 in windows 10.
Thanks,
Kaawn
Solved! Go to Solution.
08-12-2019 11:28 AM - edited 08-12-2019 11:29 AM
Hi Kaawn,
In practice this should not really happen because you should have a well-defined data format. However it is fun to think about some solutions for it. If the data can only be letters or numbers, but not both, then problem is quite easy. You can search for any digits, 0-9, and if they exist it's a number. If the data can be mixed, like a username, then it can get trickier.
08-12-2019 11:55 AM
It only matters if the number actually means something and the numeric value is actually used later for some calculations. if not, just read and display everything as a string.
In the most general case, there is no way to tell the difference. It could be many things (integer, floating point, timestamp, path, string, etc.).
If this is a real Excel file, maybe there is a way to read out the field formatting?
08-12-2019 12:57 PM
Hi Gregory,
Yes that helps, but what if my data is mixed like lets say unit2. How would I do it in this case?
Thanks,
Kaawn
08-12-2019 01:46 PM
@kaawn wrote:Yes that helps, but what if my data is mixed like lets say unit2. How would I do it in this case?
What is "it" that you want to do? You want the number 2, the string "unit2", or something else?
Gregory already gave you a mixed case (LabVIEW2019).
08-12-2019 01:47 PM - edited 08-12-2019 01:50 PM
If it's exactly like that, you could do it like my third example.