LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from Text File.vi adds spaces between characters

I'm openning a text file in LabVIEW, and and need to parse some information from it.  However, when I open the file, there are extra spaces between the letters.  When I just open the same file with Notepad or Wordpad, the spaces are not there.  Is there a way to eliminate this problem?

0 Kudos
Message 1 of 9
(4,668 Views)

The only thing that Read from Text File would do is to convert the EOL character if you have the function set up to do so. As the Help for that function describes:

 

The function converts all platform-dependent end-of-line characters to line feed characters unless you right-click the function and remove the checkmark next to the Convert EOL shortcut menu item. If you wire a path to file, the function opens the file before reading from it and closes it afterwards.

 

So, are you reading a text file that was created on another platform? If not, then provide an example of the text file you are reading and the actual LabVIEW code you are using to read the file.

 

Another possibility is that your text contains non-printable characters which Notepad and Wordpad convenienly hide. But they're still there.

0 Kudos
Message 2 of 9
(4,656 Views)

It's probably a unicode file.  Certain languages in Windows can't use one byte for a character, and thus need to use 2.  If you end up using English (or any other that do fit in one byte, you'll see these spaces (I think they are actually null characters).

 

Rolf posted a library here that will do the translation back and forth.

 

You could also open the file in something like Notepad++ which will allow you change the encoding.

Message 3 of 9
(4,649 Views)

I've attached a sample text file that I am using.  Again, if you open it with Notepad, it looks normal.  However, opening it in LV the extra spaces are there.

Download All
0 Kudos
Message 4 of 9
(4,641 Views)

As suspected by Matthew, it's a unicode file. The header for the file is FF FE. The LabVIEW functions do not handle unicode files. Use the library that Matthew pointed to.

0 Kudos
Message 5 of 9
(4,630 Views)

And, since after the \FF\FE, every other character is \00, you can even do a homebrew quick&dirty solution.

 

Are the files always like that, or are some "normal"?

 

 

Message 6 of 9
(4,625 Views)

Was this text created with a Labview program, or some instrument?



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 9
(4,623 Views)

It was created in another program....not LabVIEW

0 Kudos
Message 8 of 9
(4,615 Views)

ugh thank you for this, saved my absolute bacon, I was wasting time manually solving each problem because I didn't know the U8 converter could do that, or even what it did at all if i'm being honest.

0 Kudos
Message 9 of 9
(3,299 Views)