Welcome Guest | My Membership | Login

Tech Tip: Reality CSV Files

Article

Interacting with delimited file structures for import and export is very important within your enterprise software. Comma Separated Values format is the most common.

Reality has included an easy format for interacting with CSV files. By using the MAKE-SPECIAL TCL command, you can create a Q-POINTER like file that will turn a CSV file into a MultiValue file. This allows you to use standard SELECT/LIST/SORT statements, and MultiValue Basic OPEN/READ/WRITE statements against the data.

You will need to provide a few options to help define how to interact with the CSV files, but the general syntax is

 
MAKE-SPECIAL {filename} CSV {filepath}

For example,

 
MAKE-SPECIAL UNION CSV C:\temp\union.csv

This will turn the CSV file in figure 1 into a Q-Pointer that displays the output found in figure 2.

"Surname","City","Country"
"Wilkinson","Newcastle","UK
"O'Driscoll","Dublin","Eire"
"Michalak","Paris","France"

Fig. 1

:LIST UNION

Page    1                               13:43:58  06 Apr 2005
Surname... City...... Country...

Wilkinson  Newcastle  UK
O'Driscoll Dublin     Eire
Michalak   Paris      France

3 Items listed.
Fig. 2

The command will create dictionary names based on the heading row. The dictionary names will be created by removing all the extra spaces in the column description and replacing the remaining spaces with periods. Eg, "First Name" becomes First.Name

There are a few options that will come in handy when working with CSV files. Since not all CSV files include headers in the first line, you have the ability to define them yourself.

Include NOHEADING to tell the Q-Pointer that there is no Header line in the CSV file.

 
MAKE-SPECIAL UNION CSV c:\temp\union.csv NOHEADING

No Dictionary items will be created when NOHEADING is supplied.

Do you have a Tech Tip to share? E-mail it to editor@intl-spectrum.com

 

# # #          # # #          # # #

 

Related Articles

  • Convert C#/VB.NET Date/Time to Internal Date

    This Article will show you how to convert a C# or VB.NET Date/Time object into an Internal MultiValue Date. It will show you how to do it using the ICONV functions, and well as how to generate an Internal Date without using the ICONV function.

  • Convert Internal Date into C#/VB.NET Date/Time

    This article will show how to convert a MultiValue (PICK) Internal Date into a DateTime object that you can use in C# and VB.NET. The article will cover how use the OCONV statement, as well as, how to generate the DateTime object without using the OCONV statement.

  • Numeric to Alpha Translation

    Database: D3, Advanced Pick, AREV, jBase, Mentor/PRO, mv*Base, mvEnterpise, OpenInsight, OpenQM, Reality, Ultimate, UniVerse, UniData, UniVision

    The attached subroutine will convert a numeric values to their alphabetic values. The number "4" converts to "four"; "25" converts to twenty five, etc. There is also an option that will allow you to change a numeric value into an alphabetic count. For example, 4 converts to "forth", "25" converts to twenty-fifth.


Return to top