LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

why there's only one column in the array?

Hellow! i met a problem,please see my attached VI file,when i input the following data in the text file control and run the vi,
1 2.0 3.0
2 5.0 6.0
3 7.0 8.0

the array indicator only show the first column in the text file control,any one can tell me the reason? thanks!
0 Kudos
Message 1 of 8
(3,091 Views)
The problem is that you don't have a delimiter wired to the spreadsheet string to array function. The function is using the default delimiter, which is a tab. Since you can't use a tab delimiter in a text control. If you'll wire a space constant to the delimiter input of the string to array function as in the modified vi that I have attached your program should work nicely.
0 Kudos
Message 2 of 8
(3,091 Views)
could you please give me a LABVIEW 7.0 version,i can not open Version 7.1 VI,thanks!
0 Kudos
Message 3 of 8
(3,091 Views)
Here it is in 7.0
0 Kudos
Message 4 of 8
(3,091 Views)
Thanks a lot! it really work!
0 Kudos
Message 5 of 8
(3,091 Views)
Hellow! i met another problem,
i notice the number of space i input as the delimeter will influnce the result,for example,if the text file is as following:
1.0 2.0 3.0;
2.0 4.2 5.0;
5.0 6.0 7.0;

then the result will be quite different,so what can i do to solve this problem? thanks!
0 Kudos
Message 6 of 8
(3,091 Views)
This will happen with any text to spreadsheet function. Each instance of the delimiter will go to the next field. So, if the text has three spaces (delimiters) between two numbers, the spreadsheet will have two default value cells between those numbers.

String (\ format, for clarity):"1.0\s2.0\s\s\s3.0;"
Array:1.0 2.0 0.0 0.0 3.0

The only way to avoid this is to constrain the text. Either make sure the extra spaces are not entered or edit them out. If you are certain that there will always be an explicit number in each cell in the text, you could use the string functions to eliminate all multiple spaces.

Lynn
0 Kudos
Message 7 of 8
(3,091 Views)
When you use a space as the delimiter then every time that there is a space LV treats it as a new column. Thus you have empty columns which result in zeros. You should make sure that there is only one delimiter between each column. You might try adding a comma (or some other standard character) as your delimeter and avoiding the number of spaces altogether. If you absolutely have to use a varying number of spaces as your delimeter then you could use the search and replace string function to remove the unwanted spaces.
0 Kudos
Message 8 of 8
(3,091 Views)