Day 08: Writing Text Files

NI Self-Paced Online Training

Todays LabVIEW Core1 module, Writing and Reading Data to File, is a comprehensive look at using LabVIEW to interact with data in files.  There are some high level routines in LabVIEW that are amazingly simple to use when one wants to write data to or read data from spreadsheet formatted data files.  However, if you wish more flexibility there are a number of lower-level routines that can be used.  This module explains both approaches and also talks about the advantages and disadvantages of three main data file formats: text files, binary files, and TDMS files.  We will have a separate module on TDMS data files later.  

Access LabVIEW Core 1 Course  

  • Core 1: 11. Writing and Reading Data to File
Tab-Delimited Text Files

In LabVIEW we can write data to and read data from a variety of different file types.  The easiest type of file to work with is a plain text file.  These files end with a *.txt extension and can be opened and edited by text editors such as Notepad.  If the file is formatted with tab characters separating columns of data then it is called a tab-delimited text file.  If the data is separated by commas then it is called a comma-separated value (*.csv) file.  Both of these file types can be read by Microsoft Excel.

This video describes how to use a single built-in VI called “Write Delimited Spreadsheet.vi” to write 1D (column) or 2D (table) data to a file that can be opened with Microsoft Excel.  Note when acquiring data continuously for an unknown number of iterations, as we do when using a while loop, using this approach is not the best idea.

This video shows how the data can be written to a file as it is acquired using an Open-Write-Close model.  This approach also has the advantage that data headers can easily be added to the file.

Day 08 Topics

Our focus today is on learning to write data to tab-delimited text files.  We will spend time finishing up the Temperature Monitor assignment.

Print Friendly, PDF & Email