LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Period to coma conversion

Solved!
Go to solution

Hi, 

my problem is as following:

I want to open an existing .txt file, which is basically three columns of numbers. I need to take the 3rd column (index 2) and change it to square array so I can view it as a 3D surface. Everything went fine until I received another file where decimal separators are periods instead of comas. LabVIEW refused to draw my 3D surface and it seems that it cannot even receive numbers from the file. I tried to change the column index (0 and 1 column are only integers) but every time the output array was filled with 0's. 

How can I quickly change those periods to comas and maybe give the user the ability to choose, wheter there are periods or comas in the file?

 

Thanks!

 

PS.

I tried Tool--> Options --> Use localized decimal point... and nothing happened. 

0 Kudos
Message 1 of 9
(3,515 Views)
Solution
Accepted by Oficmajster

In the text files, what is the delimiter?  Tab?  Comma? (those are the two common ones)

 

If the files are tab delimited, then read the entire file as a single string and use the Search And Replace String to replace the periods with commas.



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 2 of 9
(3,510 Views)

Thanks, period to coma conversion works fine and dandy. But I still cannot view it as a 3D surface, what wasn't any problem before. I read the file and there are only 0's, so the surface is simply flat. Do I need to change anything else?

 

0 Kudos
Message 3 of 9
(3,498 Views)

Are you sure the file is formatted the way you want (right number of columns, data in the right columns, etc.)?  Does the file even have data?



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 4 of 9
(3,496 Views)

Yes, everything is fine. The file is not empty, there is right amount of columns and rows, but for some reason the surface comes back flat. Using the same block diagram for different files (e.g. those filled with random numbers generated in C++) it worked. But on this certain file it does not.

I attach screenshot of my block diagram.

0 Kudos
Message 5 of 9
(3,481 Views)

Where's the code where you changed the periods to commas?  Or did you just save over the text file?  Did you load the proper file?



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 9
(3,471 Views)

Yeah I saved it and then loaded changed file. The file itself seems fine, periods are changed to comas, right number of columns etc. This block diagram draws nice 3D surface when I use different file. Maybe it is something with the data?

The file looks like this:

0 0 -5,3926
0 1 -4,80885
0 2 -3,70903
0 3 -2,78994
0 4 -4,29733
0 5 -3,93188
0 6 -4,21874

 

and so on. Is it possible that LabVIEW has some problems with the data and I need to change it?

0 Kudos
Message 7 of 9
(3,467 Views)

Does your "Output Array" look correct?  I am not familiar with the 3D Surface VI.  But as long as the data going in looks good...



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 8 of 9
(3,456 Views)

I restarted my computer and it startef working. No idea why but it seems ok now.


Thanks for help 🙂

0 Kudos
Message 9 of 9
(3,441 Views)