Read a .csv file and display its content via a table control

We create a table variable and fill it from the .csv file with two CopyText commands. Then we display the content with Table  and Column.

The .csv file contains a list of cities, with population and geo coordinates:

 We display it in the following form:

Remark: The following tip "Selecting rows of a table variable" will show a more sophisticated version of this example

GuiXT Script

// first time? then create the table variable and load the content
if not V[cities.rowcount]

  // create table variable
  CreateTable V[cities] city latitude longitude country countrycode population

  // load content from .csv file
  CopyText fromFile="C:\temp\cities.csv" toText="cities"
CopyText fromText="cities" toTable=V[cities] delimiter=";"

  // sort
  Sort V[cities] orderby="countrycode,city"


// display city table
Table (2,2) (21,104) name="cities" fixedcolumns=6 _
title="&V[cities.rowcount] cities"

Column "CC" size=3 name="countrycode"
Column "City" size=30 name="city"
Column "Country" size=30 name="country"
Column "Population" size=12 name="population"
Column "Latitude" size=10 name="latitude"
Column "Longitude" size=10 name="longitude"