11-05-2012 07:15 AM
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.
Solved! Go to Solution.
11-05-2012 07:29 AM
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.
11-05-2012 08:17 AM
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?
11-05-2012 08:21 AM
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?
11-05-2012 09:35 AM
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.
11-05-2012 09:56 AM
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?
11-05-2012 10:06 AM
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?
11-05-2012 10:25 AM
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...
11-05-2012 11:58 AM
I restarted my computer and it startef working. No idea why but it seems ok now.
Thanks for help 🙂