Connexions

You are here: Home » Content » File I/O VIs and Functions
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
Affiliated with (?)
This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • This module is included in aLens by: National InstrumentsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "A full introductory course on programming with LabVIEW."

    Click the "National Instruments" link to see all content affiliated with them.

    National Instruments
Also in these lenses
  • This module is included inLens: Connexions Books Available for Print on Demand
    By: ConnexionsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "This book is available through the Connexions beta version of print-on-demand from online materials."

    Click the "Printable Books" link to see all content selected in this lens.

    Printable Books
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

File I/O VIs and Functions

Module by: National Instruments

Summary: In this lesson, you will learn about file I/O operations.

File I/O operations pass data to and from files. Use the File I/O VIs and functions located on the Functions>>All Functions>>File I/O palette to handle all aspects of file I/O, including the following:
  • Opening and closing data files
  • Reading data from and writing data to files
  • Reading from and writing to spreadsheet-formatted files
  • Moving and renaming files and directories
  • Changing file characteristics
  • Creating, modifying, and reading configuration files

File I/O VIs

The File I/O palette is divided into four types of operations: high-level, low-level, advanced, and express.

High-Level File I/O VIs

Use the high-level File I/O VIs located on the top row of the Functions>>All Functions>>File I/O palette to perform common I/O operations. Refer to the High-Level File I/O VIs section for more information about the high-level File I/O VIs.
You can save time and programming effort by using the high-level VIs to write to and read from files. The high-level VIs perform read or write operations in addition to opening and closing the file. If an error occurs, the high-level VIs display a dialog box that describes the error. You can choose to halt execution or to continue. However, because high-level VIs encapsulate the entire file operation into one VI, they are difficult to customize to any use other than the one intended. Use low-level VIs for more specific tasks.

Low-Level and Advanced File I/O VIs and Functions

Use the low-level File I/O VIs and functions located on the middle row of the Functions>>All Functions>>File I/O palette and the Advanced File I/O functions located on the Functions>>All Functions>>File I/O>>Advanced File Functions palette to control each file I/O operation individually.
Use the principal low-level functions to create or open a file, write data to or read data from the file, and close the file. The low-level VIs and functions can handle most file I/O needs. Refer to the LabVIEW Basics II: Development Course Manual for more information about the Advanced File I/O functions.

File I/O Express VIs

The Express VIs on the File I/O palette include the Read LabVIEW Measurement File Express VI and the Write LabVIEW Measurement File Express VI. The LabVIEW measurement data file (.lvm) is a tab-delimited text file you can open with a spreadsheet application or a text-editing application. In addition to the data an Express VI generates, the .lvm file includes information about the data, such as the date and time the data was generated.
Refer to the Data Acquisition and Waveforms section, for more information on using the File I/O Express VIs.

LabVIEW Data Directory

dddIcon.png Use the default LabVIEW Data directory to store the data files LabVIEW generates, such as .lvm or .txt files. LabVIEW installs the LabVIEW Data directory in the default file directory for your operating system to help you organize and locate the data files LabVIEW generates. By default, the Write LabVIEW Measurement File Express VI stores the .lvm files it generates in this directory, and the Read LabVIEW Measurement File Express VI reads from this directory. The Default Data Directory constant, shown in 1, and the Default Data Directory property also return the LabVIEW Data directory by default.
Select Tools>>Options and select Paths from the top pull-down menu to specify a different default data directory. The default data directory differs from the default directory, which is the directory you specify for new VIs, custom controls, VI templates, or other LabVIEW documents you create.

Basics of File I/O

A typical file I/O operation involves the following process:
  1. Create or open a file. Indicate where an existing file resides or where you want to create a new file by specifying a path or responding to a dialog box to direct LabVIEW to the file location. After the file opens, a refnum represents the file. A reference number, or refnum, is a unique identifier for an object, such as a file, device, or network connection.
  2. Read from or write to the file.
  3. Close the file.

Comments, questions, feedback, criticisms?

Discussion forum

Send feedback