Example Code

Parse Pipe Delimited String Data into 2D Array of Strings 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 demonstrates how to read in pipe delimited data from a text file and turn it into a two dimensions string array

 

Description

There are many ways in which text files can be delimited. Tabs and commas are the most common; however, there are many other techniques or symbols that can be used. This example focuses on pipe delimited text files.  Two common formats that utilize pipe delimiters are LEDES 1998B and HL7. LabVIEW is often used to read in data and display it in a different manner or send it to a program such as Excel using the Report Generation Toolkit. This example shows how to read in a pipe delimited text file and display it as a two dimensions string array so that it can be used by the Report Generation Toolkit.

The code reads the text file as an array of lines. Each line is then being processed in a for loop. The spreadsheet string to array function formats each line into a 1D array of strings delimited by a pipe. The output tunnel of the for loop takes care of the indexing and returns our desired 2D array.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run VI
  2. When prompted for a file, browse to the location of DATA.txt
  3. Observe the parsed data on the front panel

 

Additional Information or References
VI Block DiagramParse Pipe Delimited String Data into 2D Array of Strings LV2012 NI Verified BD.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.

Comments
Mads
Active Participant
Active Participant
on

You can skip the for-loop. Just read the file as a flat string, and wire a 2D-array to the type input of the spreadsheet string to array function. Like this:

simple.png

Uzzal1
Member
Member
on

Hi I am new in HL7 data parsing. Actually for my research work I need to parse this data and store it in SQL database. But as you know the data format is different from normal format with lot of delimiters and the length of each segment is different, so it is really very tough to parse this data. Can anyone please suggest me any suitable software/process that can be used to parse HL7 file and store it in SQL database within shortest possible time? Thanks for your patience.