From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-15-2017 04:44 AM
I found a function to determine the file extension, but this solution is not effective because I have to write all possible extentions so that it can read it.
This is why I want to ask if there is another method to distinguish the binary file and the text file in labview?
Thank you.
Solved! Go to Solution.
05-15-2017 06:24 AM
Technically all files are binary ... so if you cannot rely on the extension you'll have to read and check the content.
/Y
05-15-2017 07:46 AM
Have you ever used a "show all the characters" Text Editor and pointed it at an arbitrary file? You (the Human Being) can quickly tell Binary from Text because you see ... "text", meaning letters/numbers separated by spaces and broken into lines of "reasonable" length, while "Binary" files look like gibberish and lack line structure.
[Actually, as Yamaeda pointed out, all files are Binary, and a "Text" file written using Kanji characters might look pretty unrecognizable, too ...]
If I wanted to write a function that would "make a good guess" if the file was primarily ASCII Text, I'd read 1000 characters (or, perhaps, the entire file) and ask the following:
If the answer to all was "Yes", I'd say "Almost surely Text" (though I should probably analyze the entire file). Note that a LabVIEW Delimited Spreadsheet File might not have any embedded spaces, so Criterion 2, above, might be "weak" ...
Bob Schor
05-15-2017 11:13 AM
You might also be able to do something using MIME content types and check the file for any of the standard headers, but that can be slow and cumbersome, and will only catch binary data files with a known header type.