LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delimiter for the Spreadsheet string to array

Hello,
 
   I would like to use the Spreadsheet string to array function to process the data obtained from reading a text file that has 2 columns separated by at least one space character. Can the spreadsheet string to array have delimiters other than a comma or tab? 
Regards,


Kaspar
0 Kudos
Message 1 of 9
(17,850 Views)
Hello Kaspar,

just switch on the help window for the 'spreasheet to array' function. There's an input to change the default delimiter (tab)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(17,842 Views)
Hello,
 
   Ok, I changed the delimiter character of a %s, so that I can use white spaces (at least one or more) to separate the columns in the text file. I am still getting a 17 by 1 array output as oppossed to a 17 by 2 array output
Regards,


Kaspar
0 Kudos
Message 3 of 9
(17,836 Views)
When you entered the %s, did you also select '\' Codes Display for the string constant? Also, specifying a single space as a delimiter means that the columns have to be separated by exactly one space. If you have more spaces than that, your data will have some extra 0's in it.
Message 4 of 9
(17,831 Views)
Ok, thanks for the info. How can I specify a delimiter so that I can have more than one whitespace as a delimiter in the text file?
Regards,


Kaspar
0 Kudos
Message 5 of 9
(17,825 Views)
Hi Kaspar,

in a first attempt I would use this:

The vi searches for two consecutive space chars and replaces them with just one spaces. This is done again as  long as it finds a match. Then a normal spreadsheet to array will follow...

Message Edited by GerdW on 06-29-2006 04:59 PM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(17,814 Views)
Depends on what you mean. If you always have two spaces for example, you can just specify that as the delimiter. If the data is sometimes separated by 1, sometimes by 2, sometimes by some other count, you could use a Search and Replace Pattern before the Spreadsheet String to Array. Try \s?\s as the regular expression and \s as the replace string.
Message 7 of 9
(17,809 Views)
Alternatively, you can do the conversion using "scan strings for tokens" in loops. One nice feature is the fact that you can have an unlimited selection of alternative delimiters and by default, consecutive separators are contracted into one (in other words, empty tokens are skipped). Sometimes users might manually edit ASCII data files and the delimiters are suddenly a random mix of several spaces and/or tabs  (Gerd's solution above might not work in this case).
 
Message 8 of 9
(17,795 Views)
Here's an example of what I had in mind (LabVIEW 8.0). (The delimiter constants are displayed in "'\'-codes").
 
As you can see, it ignores consecutive delimiters (even empty lines ;))
 
 

Message Edited by altenbach on 06-29-2006 09:10 AM

Message 9 of 9
(17,787 Views)