11-13-2012 08:36 AM
Hello
I am trying to read a .txt file with some measurements in it.
The problem is, that the measurements are written in a column with a . (dot) like:
0.453
-3.567
etc…
The Read From Spreadsheet File.vi, as I see, has problems with that – I don’t get any data at all. When I upload a .txt file, with measurements have a , (coma), everything works fine.
So – is there a way to change some options in The Read From Spreadsheet File.vi to make it read my measurements with . (dots)?
Thank you for any help.
11-13-2012 08:48 AM
There shouldn't be a problem with reading decimal numbers. What is your delimiter character (it is set to Tab Delimited by default)? Can you upload a portion of your data?
11-13-2012 09:01 AM
This looks like a localization problem. One solution I've seen is the read the entire file as a string, use the Search and Replace String to convert all of the periods into commas, and then use the Spreadsheet String to Array (use %f as the format) to get your array. This should work since you are dealing with only a single column.
11-13-2012 09:51 AM
If the problem is localization - It sounds like it - you could try changing the localisation for this read.
I have my localization set so that the decimal separator is a period, thus I have problems in reading 2,5 as meaning two-and-a-half. However if I use the "set localisation" option make comma the decimal separator will read it correctly. I put "%,;" (Percent, comma, semicolon) at the beginning of the format string, keeping the existing characters.
So applying the opposite may work for you.
Assuming that you currently use %f as the format string in read from spreadsheet file, try using %.;%f instead (Thats percent, period, semicolon, percent, f)
Rod.
11-14-2012 04:18 AM
Hey.
Thanks for the replays. The method Rob suggested worked just fine, so Im quite happy.
If I may just ask one more question, it's not so important, but still, I'd like to know that for the future 🙂
What would I have to change in The Read From Spreadsheet File.vi, if the data I wanted to load would be written not in columns but rows?
for example: 2.567 -1.545 -0.456 2.986
is it also a localization problem?
11-14-2012 06:32 AM
For rows you would need to know what the delimiter is. The default is tab, but space and comma are also fairly common. If comma, you could run into your localization issues.
11-15-2012 03:03 AM
Thank you for the reply, it was really helpful.