How to Read, Validate, and Write CSV Data in TestStand

Updated Jul 14, 2026

Environment

Software

  • TestStand

This document explains how to configure CSV input and output streams in NI TestStand™ to read structured data, process it using expressions, and write results to a new CSV file.
You will:
  • Define a data container for CSV mapping
  • Read input data from a CSV file
  • Perform calculations and validation
  • Write processed data to an output CSV file
Requirements:
  • NI TestStand™ installed
  • A CSV file with headers (for example: Input1, Input2, Input3, Input4, Input5, Expected)

Create Local Variables for Data Handling as instructed below:
  • Navigate to the Variables pane.
  • Create a container variable:
    • Name: Locals.RowData
    • Type: Container
  • Add the following fields inside Locals.RowData:
    • Input1 (Number)
    • Input2 (Number)
    • Input3 (Number)
    • Input4 (Number)
    • Input5 (Number)
    • Expected (Number)
    • Actual (Number)
    • Result (String)
  • Create additional variables:
    • Locals.InputStream (Object Reference)
    • Locals.OutputStream (Object Reference)

 

Prepare the Input CSV File
  • Create a CSV file (for example, TestStand_Demo.csv) with the following header row:
    Input1, Input2, Input3, Input4, Input5, Expected
    
  • Populate rows with numeric values.

 

Configure the CSV Input Stream
  • Add a New CSV Input Stream step in the sequence.
  • Set:
    • CSV File Path input file path (for example, D:\TestStand_Demo\TestStand_Demo.csv)
    • Input Record Stream Reference Locals.InputStream
    • Separator Character Comma
    • Enable Skip Lines = 1 (to ignore header row)

 

Configure the CSV Output Stream
  • Add a New CSV Output Stream step.
  • Set:
    • CSV File Path output file path (for example, D:\TestStand_Demo\TestStand_Demo_Out.csv)
    • File Open Mode FileOpenMode_Truncate (Note: This helps to overwrite the existing file)
    • Output Record Stream Reference Locals.OutputStream
    • Field Headers Locals.RowData (Note: This helps to write the Header Row in the Output file in the same order mentioned in RowData container)
    • Separator Character Comma

 

Add a Stream Loop to Process Data
  • Insert a Stream Loop step in the sequence.
  • Configure the loop to read from Locals.InputStream.
  • Map each row into Locals.RowData.

 

Calculate the Actual Value

Add an Expression step inside the loop:

Locals.RowData.Actual =Locals.RowData.Input1 +Locals.RowData.Input2 +Locals.RowData.Input3 +Locals.RowData.Input4 +Locals.RowData.Input5

 
 
Compare Expected and Actual Values

Add another Expression step:

Locals.RowData.Result = (Locals.RowData.Actual == Locals.RowData.Expected)? "Pass": "Fail"

 


Write Processed Data to Output CSV

Add a Write Record step inside the loop and configure as mentioned below to record the RowData to the Output CSV file.

 


Run the Sequence
  • Execute the sequence.
  • Verify that the output CSV file is created with additional columns for Actual and Result.

After completing these steps:
  • The input CSV data is read row by row.
  • The sum of Input1–Input5 is calculated as Actual.
  • Each row is validated against the Expected value.
  • The output CSV file contains:
    • Original inputs
    • Calculated Actual value
    • Validation result (Pass or Fail)