LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading file . to , problem

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. 

 

0 Kudos
Message 1 of 7
(2,375 Views)

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?

0 Kudos
Message 2 of 7
(2,371 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(2,367 Views)

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.

 

 

0 Kudos
Message 4 of 7
(2,355 Views)

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?

0 Kudos
Message 5 of 7
(2,329 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 7
(2,317 Views)

Thank you for the reply, it was really helpful.

 

0 Kudos
Message 7 of 7
(2,296 Views)