05-07-2012 03:27 AM - edited 05-07-2012 03:36 AM
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 imported into an array (note the spaces and empty rows):
vi:
Solved! Go to Solution.
05-07-2012 03:38 AM
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.
05-07-2012 03:52 AM
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.
05-07-2012 05:04 AM
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.
05-07-2012 05:08 AM
Thank you, I got it and it works.