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 WW156 How to create a string of data for a CSV file

Last updated: March 6th, 2025

Description

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

Details:

Description

This article from InSource shows how to use the StringBuilder() class to create a string of data for a Comma Separated Values or CSV file. 

  • Author: Michael Walker
  • Published: 03/16/2016
  • Applies to: Wonderware Application Server (All Versions)

Details

When scripting the content of a .CSV file, the StringBuilder class should be used. Using the StringBuilderprovides a memory efficient way to build content for a .CSV file, with the ability to append multiple string values and records together. Using the “ + “ operator to build strings could be used, however each string that is called to be appended will create a new string object in memory, therefore making the script inefficient. The StringBuilder class will be declared as a variable of type System.String.StringBuilder. Before using the string builder, the declared variable has to be set to a new System.Text.StringBuilder(); Using the newly declared variable values can be appended using the .Append() Method, also the .AppendLine() method can be used to add a new line within the .CSV content string. The figure below shows a script that creates new StringBuilder variable and populates it with data. It then sends the string as a message to the system Management Console.

The resulting message is logged to the SMC log viewer.

Value 1, 1234, HELLO WORLD!, 3/9/2016 3:21:24 PM

Value 2, 5678, HELLO WORLD, AGAIN!, 3/9/2016 3:21:24 PM

Attached is a text document that provides the sample script. 

data string csv creation
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