10-30-2012 11:24 AM
Hi
I am trying to split a delimited string and output an array of the results.
I come from a .net background and the C# code I would use would be
string mystring = "mystring\r\nto\r\nsplit";
string[] myString = mystring.Split(newchar[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
The above code have a muli line string on the input (hence the \r\n) and output an array with the following contents
"mystring"
"to"
"split"
Additionally I would like to support comma delimited files as well.
I have used the string function
"Spreadsheet String To Array" which works well enough for comma delimted lines, but not when the delimiter is something funky like '\r\n'.
Solved! Go to Solution.
10-30-2012 11:43 AM
I think maybe "Match Pattern" or use the "Spreadsheet String To Array" looking for the first control character, then using "Trim Whitespace" to trim the other off the front of each element of the resulting array. That's kind of clunky though.
10-30-2012 11:47 AM
in vi.llb in the advanced string folder there are a few goodies that did not make it to the pallates
10-30-2012 11:51 AM
@JÞB wrote:
in vi.llb in the advanced string folder there are a few goodies that did not make it to the pallates
Cool! 🙂
10-30-2012 11:53 AM
well that loooks good to me, it works 🙂
where excatly do i find that vi.llb file and where is it documented?
sounds like there may be more functions in it which might be useable,
are there more hidden functions stashed away somewhere if so where are they and are they documented somewhere?
Thanks again
10-30-2012 12:16 PM
@JacobM123 wrote:
well that loooks good to me, it works 🙂
where excatly do i find that vi.llb file and where is it documented?
C:\Program Files\National Instruments\LabVIEW 2012\vi.lib\AdvancedString It is not documented anywhere in the LabVIEW help, that is one of the reasons it does not exist on the pallates
sounds like there may be more functions in it which might be useable,
are there more hidden functions stashed away somewhere if so where are they and are they documented somewhere?
Beware- digging through undocumented code in vi.lib should be done with care it is not for the feint of heart many of the vis found there are tested to a very specific task (like helper vi's for implementing feature set xyz) you can and probably will run across some use cases where you obtain unexpected results. Again no published LabVIEW help but many have been the subject of community nuggets that explain their use
Thanks again
C:\Program Files\National Instruments\LabVIEW 2012\vi.lib\AdvancedString
10-30-2012 02:35 PM
"Spreadsheet String to Array" works fine for multiline strings (each line terminated with \r\n).
10-30-2012 05:22 PM
@MIG wrote:
"Spreadsheet String to Array" works fine for multiline strings (each line terminated with \r\n).
Th OP wanted to delimit the string using either a comma or an end of line. Therefore you would need to wire an array containing the various choices for the delimiter.
A note for the OP. In LabVIEW you need to look at teh help carefully since it doesn't always make it clear that a VI can accept various types of inputs. The Spreadsheet String to Array is polymorphic and will accept either a single string constant or an array for the delimiter.