Example Code

Read Fixed Width Data 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

Download All

 

Overview
Some input files will be in a fixed width format. These can be relatively easily interpreted by loading them in to memory as strings and then converting them numerically, but for very large files and systems with modest resources this could be problematic. This vi solves that problem. 


Description
This vi uses a series of loops to parse the line of hyphens and spaces below the column headers and calculate column width and number of columns. It then uses the scan file vi, along with the calculated column width and number, to read the numeric values directly from the file, bypassing the conversion from strings and thus saving memory.

 
Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Format the data file to have the line separating the data from the header in the manner illustrated in the attached example file.
  2. Create code to parse the header data as required.
  3. Process the data as desired. 

 

Additional Information or References
VI Block Diagram

 1.png

 

**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.