Text Files
- Updated2026-05-01
- 2 minute(s) read
Text files store data as text strings for easy sharing across applications and computers. When using text I/O, Consider tradeoffs compared to binary files, such as file size, I/O speed, random access limits, and numeric precision.
Use text format files if all of the following conditions are true:
- If you want to make your data available to other users or applications
- If disk space and file I/O speed are not crucial for your application
- If you do not need to perform random access reads or writes
- If numeric precision is not important
Text files are the easiest format to use and to share. Almost any computer can read from or write to a text file. A variety of text-based programs can read text-based files. Most instrument control applications use text strings.
Store data in text files when you want to access it from another application, such as a word processing or spreadsheet application. To store data in text format, use the String functions to convert all data to text strings. Text files can contain information of different data types.
Text files have some disadvantages relative to binary files.
- Text files typically use more memory than binary files or datalog
files for data that is not originally in text form. Graph or chart data are examples of such
data. The ASCII representation of data usually is larger than the data itself. For
example:
- You can store the number –123.4567 in 4 bytes as a single-precision floating-point number.
- However, the ASCII representation takes 9 bytes: one for each character.
- It is difficult to randomly access numeric data in text files. Although each character in a string takes up exactly one byte of space, the space required to express a number as text is typically not fixed. To find the ninth number in a text file, LabVIEW must first read and convert the preceding eight numbers.
- You might lose precision if you store numeric data in text files. Computers store numeric data as binary data, and typically you write numeric data to a text file in decimal notation. A loss of precision might occur when you write the data to the text file. Loss of precision is not an issue with binary files.
Use the File I/O VIs and functions to interact with text-based files.
Text File I/O Examples
Refer to the following VIs for examples of using file I/O with text files:
- labview\examples\File IO\Text (ASCII)\Text (ASCII) Files.lvproj
- labview\examples\File IO\Spreadsheet\Tab-Delimited Data\Tab-Delimited Data.lvproj