Example Code

Parse a CSV in 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

1. Overview:
This example VI reads a CSV file with header and gets the data in a double array 

 
2. Description:
A CSV (Comma Seperated Values) file is a a database exported into a file format where each record is a single line and each field in the record is seperated by a comma.  They may also sometimes contain header information.  To parse a CSV file you must simply read the file as a text fiel, remove the header, and then parse the data using the "Spreadsheet String to Array" function.


3. Requirements

  • LabVIEW 2012 (or compatible)

4. Steps to Implement or Execute Code

  1. Unzip the attached folder to your computer
  2. Open the VI "Parse CSV to Doubles Array LabVIEW 2012 NI Verified.vi"
  3. Select "data.csv"
  4. The End Of Header parameter must be the same character used in the csv file for delimiting End Of Header (by default "--")
  5. Run the program
  6. Once the program is run, the complete text in the csv file, the header and the numeric array are shown in the front panel.

5. Additional Information or References

VI Block Diagram

 

VI Block Diagram.JPG

 

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

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