Some content on this site is available only to logged-in subscribers. Contact Us for information on becoming a subscriber.

InSource.Solutions | InSource Training | InSource Client Portal
InSource Solutions Logo
Log In Sign Up
InSource.Solutions InSource Training InSource Client Portal Log In Sign Up
  • Home
  • AVEVA Application Server
  • AVEVA Application Server Tech Notes

TN Appsvr116 Reading a CSV file into AppServer UDA's

Last updated: March 6th, 2025

Description

  • Author: Brian Schneider
  • Published: March 6th, 2025

Details:

Description

This is a simple scripting example to demonstrate how to read a CSV file into UDA arrays. The scripting uses QuickScript .NET functions and is intended for Application Server.

Before you Begin

Create the required UDA array for each column in the CSV file, if not already existing. 

Detailed Steps

There are many options in .NET for reading CSV files. The scripting example given here uses 
the System.IO.StreamReader class. It is built for a three column CSV file as shown below. 

Each line of the CSV file is read in using the ReadLine method. The columns are parsed out 
using the various String methods. A while loop looks for the end of the file using the Peek 
method. Below is a screen capture from the IDE.

The following is the example scripting used.

dim s as string; 

dim sr as System.IO.StreamReader; 

dim stringlength as integer;

dim firststring as string;

dim secondstring as string;

dim thirdstring as string;

dim remainderstring as string;

dim index as integer;

sr = System.IO.File.OpenText("c:\csvtest2.txt"); 

while sr.Peek() > -1

index = index + 1; 

s = sr.ReadLine();

LogMessage(s);

stringlength = StringInString(s, ",", 1, 0);

firststring = StringMid(s,1,stringlength-1);

me.FirstUDA[index] = firststring;

remainderstring = StringRight(s, StringLen(s) - stringlength);

stringlength = StringInString(remainderstring, ",", 1, 0);

secondstring = StringMid(remainderstring,1,stringlength-1);

me.SecondUDA[index] = secondstring;

thirdstring = StringRight(remainderstring, StringLen(remainderstring) -

stringlength);

me.ThirdUDA[index] = thirdstring;

endwhile; 

me.ParseIT = 0;

The object hosting the script was deployed from the IDE and tested out from the Object Viewer. 
Each column has been parsed out to their respective UDA.

 

csv file appserver uda's
Give feedback about this article

Recommended articles

TN - 1240 Creating a Watchlist Using an Import File

Read More

How to receive group emails

Read More
Support Icon

CONTACT SUPPORT

How to reach us

10800 Midlothian Turnpike Tpke, Suite 209, Richmond, VA 23235

1.877.INSOURCE

Technical Support - 1.888.691.3858

Contact Us

  • InSource Solutions
  • InSource Training
  • InSource Client Portal
  • Log In
InSource Solutions Logo

© 2025 InSource Solutions. All Rights Reserved.

Knowledge Base Software powered by Helpjuice

Expand