LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

text manipulation

OK guys, easy one today.
I have an excell file with numbers and text.
I want to scan the data for a known set of text eg "MFC Serial Number :", then take the next part of text and use it elswhere. The text I scan for is always the same length which is easy, but the text I take can vary in length but will always be in the next column in the excell file. So in other words I want to scan an excell file horizontaly along the columns until I match the text, then I want to take the next box of data horizontaly BUT NOTHING ELSE (this is where I fall down). Using offsets will not work as the data can be differing lengths. I am sure there's a way but it escapes me as yet.
After three, off you all GO !
cheers (again).
0 Kudos
Message 1 of 5
(3,035 Views)
Probably a number of ways to do it, but the easiest one I can think of is just to use 'load characters from file' then pass it to 'spreadsheet string to array'. You then have all you entries in boxes and it is easy to pick out the one which has an index 1 greater than your match.

In general the solution is to use delimeters to split your data up, not the field width. There are plenty of text manipulation vi's for this.

hope this helps

Steve
0 Kudos
Message 2 of 5
(3,035 Views)
Thanks for this, I have tried this before with some success. However the Excell file is saved from labview originally and is delimited using tabs and returns in the %f format. I then read the data back in using "Read Characters from File" and this works into a text box fine, I get all the numbers and all the letters as I need. But when I convert using "Spreadsheet String to Array" I loose all the data containing letters and keep all the numbers, this is no good. So close but so far.
Any help much appreciated.
Steve.
0 Kudos
Message 3 of 5
(3,035 Views)
SORTED, Load the file in using "Read Charecters from File, then use "Search and Split String" to chop the data at the correct place. Then pick a line of data you want to look at (this can be offset again and again to look at differant bits of data). Use "String Length" to get the number of numbers / letters in the data string, then I know the length of the first half of the string anyway, so I just take this string length and subtract the 'known data length', then take the answer from the first streing length. No matter how long the nbit of data I want it the sum does its stuff and works out the answer for me. Hope you are all confussed, 'cos I am. Never mind though 'cos it works.
Till the next time.
0 Kudos
Message 4 of 5
(3,035 Views)
I think there is an easier way. As Steve says, start by reading characters from file. Then convert to an array of strings! (Wire an array of strings to the lower left corner of "array to spreadsheet string", and "%s" to upper left.) Then, it's easy to get your number, it's the next element after the known text; you don't need to worry how many characters are in the number. Now convert the textual "number" into an i32 or DBL or whatever.

I'm going to try to attach a LabView 6.0 file. The read characters from file part is not included (I construct a dummy matrix of text and numbers-as-text.) It's my first time using the forum so it may not work.
0 Kudos
Message 5 of 5
(3,035 Views)