LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match pattern and null characters

Solved!
Go to solution

Hi,

 

I'm using LabView 2010 and want to write a VI that imports a spreadsheet file (txt) into an array, and then goes through the rows and looks for expressions.

 

Problem:

The "read from spreadsheet file" vi generates unnecessary spaces and empty rows and the data apparently contains null characters, so that the "match regular expression" vi returns only errors.

 

What is a null character and how do I get rid of it and how can I import the text file properly without the additional spaces and empty lines?

 

Thank you.

 

Original text file:

text file

 

Text file imported into an array (note the spaces and empty rows):

imported.PNG

 

vi:

vi.PNG

0 Kudos
Message 1 of 5
(4,512 Views)

This file is not an ASCII text file but really an UTF16 file. As such the ASCII String to Spreadsheet file obviously has to run into problems trying to interpret it. A quick and dirty approach would be to read in the file as string first, remove the first two UTF16 file indication bytes and then remove every second character. If the file does only contain 7Bit ASCII characters you are all done and can feed the resulting string to Spreadsheet String to Array, otherwise you will get some strange characters at the positions that contain non 7Bit ASCII characters.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 5
(4,501 Views)

Thanks for your input.

How would I go about and do that? It's been a while since I worked with LabView, this is my first program in quite some time.

0 Kudos
Message 3 of 5
(4,496 Views)
Solution
Accepted by topic author boxleitnerb

Reading in a file as string? How about the function right in the same palette as your Read Spreadsheet File function you have found?

And manipulation on the level you need to do it here is probably best done by converting the string into a byte array and using array functions. Then convert it back afterwards.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 5
(4,484 Views)

Thank you, I got it and it works.

0 Kudos
Message 5 of 5
(4,480 Views)