Example Code

Read and Process Comma Separated Values from a File using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI will open a file containing Comma Separated Values and read them in a loop.

 

Description

This example demonstrates how to read a list of comma separated values from a text file into LabVIEW and operate on the data one value at a time. 

 

In this case, the First Row output of the Read from Spreadsheet File VI is wired into a loop such that the values are viewed one at a time; the output is simply a 1D Array. Alternatively, all the rows in the file might be read by chosing the appropriate ouptut terminal.

 

Furthermore, there is a sample text file attached; in order to read from different files, the delimiter might need to be changed. To do so, simply change the string constant that is connected to the VI. Finally, whether the data is read as a double, integer or string needs to be chosen manually.

 

Steps to Execute

  1. Browse for the Sample Text File
  2. Run the VI
  3. Observe the Control Value indicator

 

Requirements

Software

LabVIEW 8.6 or later. Included is a LabVIEW 8.6 VI as well as a 2012 VI.

 

Additional Information or References

VI Block Diagram

3632.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

 
Sincerely,

Chris G in AE

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.