CSV Command

Lightwing can periodically read two-dimensional arrays of string data from files in the CSV (comma separated values) format and display that information with Text commands. CSV is a plain text file format that can be exported from many popular database and spreadsheet applications, like Microsoft Excel and Google Docs. This makes it easy to create signs which display dynamic information which is updated periodically without the need to edit scripts to update sign content.

        Example of a CSV File with a 5 x 4 Array

        "Item A1","Item B1","Item C1","Item D1","Item E1"
        "Item A2","Item B2","Item C2","Item D2","Item E2"
        "Item A3","Item B3","Item C3","Item D3","Item E3"
        "Item A4","Item B4","Item C4","Item D4","Item E4"

The CSV command defines a name for a CSV channel with an optional periodic update time interval. CSV channels are global, so CSV commands should appear at the top of the script file to make the channels available to all pages in the script. CSV names can be any mix of alpha and numeric characters and some symbols including underscore and hyphen. A CSV extension is appended to the end of the name to construct the file name that will be opened and read. CSV files must be located in the data folder. By default, CSV files do not update periodically and are limited to 100 items per channel. Use the command options below to change this.

The following example creates a CSV channel named Excel and reads its data from the file shown above named Excel.csv on one hour update intervals.

       Example of a Page that Displays CSV Channel Information
  
        csv: Excel    update: 1:00:00    limit: 5

        page: PageName    time 1, 10
            text: OpenSansRegular_40    lines: 4    csv: Excel    type: CsvBlock    index: 0, 0

Several variable names are available to display CSV file information using the variable option with Text commands. The Ticker command does not support CSV channels.

CSV Text Variables

        Names                  Displays
        
        CsvItem                  A single data item.
        CsvRow                  A row of multiple data items.
        CsvColumn            A column of multiple data items.
        CsvBlock                A two-dimensional array of items.

The CsvItem variable provides the most flexibility to format CSV data on the page in any manner, but requires a separate Text command for each item displayed. The CsvBlock variable will display an entire two-dimensional array of items with a single Text command, but always formats the items in consecutive order starting at the top left corner and proceeding from left to right and then top to bottom for each row of items. This assumes that the CSV file is already in that order.

CsvRow and CsvColumn offer compromises in formatting flexibility requiring a Text command per row or column, respectively. CsvBlock and CsvRow always add 3 spaces between items for horizontal spacing, which is not configurable. Alternatively, CsvColumn spaces items vertically according to the height of the font, which allows columns to have arbitrary horizontal spacing controlled by the position options of the Text commands. Refer to the TestCSV.lws script in the Lightwing SDK for examples of using these variables to display formatted data arrays.

Limit Option

Defines the maximum number of items that a CSV channel will contain in the horizontal and vertical directions, respectively. CSV channels are limited to 1000 items per channel in total, by default. These values can be used to limit the size of the data set that is read from the CSV file to any smaller sizes. If only a single value is specified, it defines the size of the channel array in both dimensions.

Update Option

Defines a time interval to update the CSV channel data by reading from the file. This can be specified as either a floating-point value in seconds or integer (sexagesimal) clock time. This interval is zero by default, which means to never update the channel.

Example Time Specifications

        Time Duration                               Float                Clock

        One Half Second                                 0.5                    n/a
        One Second                                         1.0                        1
        One Minute                                           60                  1:00
        One and One Half Minutes                90                  1:30
        One Hour                                          3600             1:00:00
        One and One Half Hours               5400              1:30:00
        One Day                                          86400           24:00:00

 

 

<   Chain Command                                             Introduction                                            Global Command   >