Write To Measurement File Express VI

Owning Palette: Output Express VIs

Requires: Base Development System

Writes data to text-based measurement files (.lvm), binary measurement files (.tdm or .tdms), or Microsoft Excel files (.xlsx).

Use the Read From Measurement File Express VI to read data from the generated measurement file.

Details  Examples

Dialog Box Options
Block Diagram Inputs
Block Diagram Outputs
 Add to the block diagram  Find on the palette

Dialog Box Options

ParameterDescription
FilenameDisplays the full path to the file to which you want to write data. The Express VI writes data to the file that this parameter specifies only if the Filename input is unwired. If you wire the Filename input, the VI writes data to the file that this input specifies instead.
File FormatContains the following options:
  • Text (LVM)—Sets the file format to text-based measurement file (.lvm) and the file extension in Filename to .lvm.
  • Binary (TDMS)—Sets the file format to binary measurement file (.tdms) and the file extension in Filename to .tdms. If you select this option, the Delimiter section and the No headers option in the Segment Headers section are not available.
  • Binary with XML Header (TDM)(Windows) Sets the file format to binary measurement file (.tdm) and the file extension in Filename to .tdm. If you select this option, the Delimiter section and the No headers option in the Segment Headers section are not available.

    When you select this file format, you enable the Lock file for faster access checkbox. Selecting this checkbox makes reading and writing significantly faster (at the expense of the ability to multitask certain activities). It is recommended that you use this option in most cases.
    Note  When this option is enabled, no two Express VIs can access the same file at the same time when one of them is writing a "series of files."
  • Microsoft Excel (.xlsx)—Sets the file format to Microsoft Excel (.xlsx) and the file extension in Filename to .xlsx. If you select this option, the Delimiter section and the Segment Headers section are unavailable.
    Note  This option does not require Microsoft Excel installed on the local computer.
ActionContains the following options:
  • Save to one file—Saves all the data to one file.
  • Ask user to choose file—Displays a dialog box that prompts users to select a file. This option is available only when you select the Save to one file option.
  • Ask only once—Prompts users to select a file only once. This option is available only when you place a checkmark in the Ask user to choose file checkbox.
  • Ask each iteration—Prompts users to select a file each time the Express VI runs. This option is available only when you place a checkmark in the Ask user to choose file checkbox.
  • Save to series of files (multiple files)—Saves the data to multiple files. If Reset is TRUE, the VI starts at the first file in the series. For example, if test_001.lvm has been saved to test_004.lvm, test_001.lvm might be renamed, overwritten, or skipped based on the value of the Existing Files option in the Configure Multi-file Settings dialog box.
  • Settings—Displays the Configure Multi-file Settings dialog box. This option is available only when you select the Save to series of files (multiple files) option.
If a file already existsThis section is available only when you select the Save to one file option from the Action section. Contains the following options:
  • Rename existing file—Renames the existing file if Reset is TRUE.
  • Use next available filename—Appends the next sequential number to the filename if Reset is TRUE. For example, if test.lvm exists, LabVIEW saves the file as test1.lvm.
  • Append to file—Appends the data to the existing file. The VI ignores the value of Reset if you select the Append to file option.
    Note  When you append data to an existing Excel file, errors might occur if the Excel file was not created by this Express VI. This option does not support appending data to an Excel file that was created by a third-party application.
  • Overwrite file—Replaces data in an existing file if Reset is TRUE.
Segment HeadersThis section is unavailable when you select the Microsoft Excel (.xlsx) option from the File Format section. Contains the following options:
  • One header per segment—Creates one header per segment in the file to which LabVIEW writes the data. Select this option if the acquisition rate of the data changes over time, if you acquire two or more signals at different acquisition rates, or if the list of signals you log changes over time.
  • One header only—Creates only one header in the file to which LabVIEW writes the data. Select this option if you acquire the same list of signals at the same constant acquisition rate.
  • No headers—Does not create a header in the file to which LabVIEW writes the data.
    Note  This option is available only when you select the Text (LVM) option from the File Format section.
X Value ColumnsContains the following options:
  • One column per channel—Creates a separate column for time data each channel generates. This option includes a column of values from the x-axis for every column of values from the y-axis. Select this option if you acquire signals of different types or at different acquisition rates.
  • One column only—Creates only one column for the time data the channels generate. This option includes only one column of values from the x-axis. Select this option if you acquire signals at the same acquisition rate.
  • Empty time column—Creates an empty column for the time data each channel generates. This option does not include the data from the x-axis.
DelimiterContains the following options:
  • Tab—Uses tabs to delimit fields in the text file.
  • Comma—Uses commas to delimit fields in the text file.
    Note  These options are available only when you select the Text (LVM) option from the File Format section.
File DescriptionContains the description of the measurement file. LabVIEW appends the text you enter in this text box to the header of the file. This text box is unavailable when you select the Microsoft Excel (.xlsx) option from the File Format section.
  • Advanced—Displays the Configure User Defined Properties dialog box when you select the Binary (TDMS) or Binary with XML Header (TDM) option from the File Format section. Displays the Configure Advanced Excel Options dialog box when you select the Microsoft Excel (.xlsx) option. This button is unavailable when you select the Text (LVM) option.

Block Diagram Inputs

ParameterDescription
ResetSpecifies whether you want to reset the data file when you run this Express VI iteratively. LabVIEW ignores this input when you run this Express VI in the first iteration. During the second and subsequent iterations, if the value is FALSE, this Express VI appends data to a file if the file already exists. Depending on your configuration for this Express VI, if the value is TRUE, this Express VI renames, overwrites, or skips a file if the file already exists. The default is FALSE.
EnableEnables or disables the Express VI. The default is ON or TRUE.
new_fileIf TRUE, stops writing to the current file, creates the next file in the series, and writes to that file instead. This input is available only when you select the Save to series of files (multiple files) option.
error inDescribes error conditions that occur before this node runs.
DAQmx TaskSpecifies the DAQmx task to use to populate data on the DAQmx Properties page of the Configure User Defined Properties dialog box.
CommentAppends a comment to each data set written to the measurement file. This input is unavailable when you select the Microsoft Excel (.xlsx) option from the File Format section.
FilenameSpecifies the name of the file to which you want to write data. If Filename is not wired, the VI uses the Filename specified in the configuration dialog box.
SignalsContains the input signal or signals. If you wire two or more signals with the same name to the Signals input, LabVIEW appends an integer to the end of the names written in the file, which enforces unique channel names. For example, if you wire two signals named Sine to the Signals input, LabVIEW writes the names as Sine and Sine 1.
Note  To change or customize how a signal name displays, use the Set Dynamic Data Attributes Express VI.
Flush?Specifies whether LabVIEW writes data to the Microsoft Excel file each time after this Express VI runs. If the value is FALSE, LabVIEW does not write the data to the Microsoft Excel file. Instead, LabVIEW stores the data in a temporary file. If the value is TRUE, LabVIEW writes the data from the temporary file to the Excel file and then purges the temporary file. The default is TRUE.
Note  If you use this Express VI to write data iteratively, setting the Flush? input to TRUE at each iteration might affect the writing performance negatively. National Instruments recommends that you wire a FALSE value to this input until the last iteration of the entire writing process. For the last iteration, you can wire a TRUE value to this input to write all data to the Excel file.

Block Diagram Outputs

ParameterDescription
Filename OutReturns the name of the file.
Saving DataIndicates if the Express VI is saving the data.
error outContains error information. This output provides standard error out functionality.

Write To Measurement File Details

Note  The behavior of this VI changes depending upon the target. If the current target does not or might not have a host computer connected, the configuration dialog box displays warnings next to options that are invalid without a host. If you configure this VI to prompt for input and run the VI on a target with no user interface, such as the Real-Time Module with no host computer connected, this VI returns an error.

You can also use the Storage/DataPlugin VIs to read from and write to .tdm files, or you can use the TDM Streaming functions to read from and write to .tdms files.

This Express VI operates similarly to the following VIs and functions:

Open/Create/Replace File
Write to Text File
Write to Binary File
Write To Spreadsheet File
File Dialog
Format Into File

Examples

Refer to the following VIs for examples of using the Write To Measurement File Express VI: