Skip to content
Data & Connectivity

LoadFile

The LoadFile command to load external files into AMI via the Relay.

Overview

The Relay is responsible for sending real-time data to and from AMI applications via the realtime messaging API. This allows external applications to interface with AMI, typically feed handlers and AMI Client applications.

In specialized circumstances, the Relay can also be used to load and read tabular data directly from a file. The Relay then streams that information to a Center table.

This page contains instructions on setting up and running the LoadFile command.

Setup

Requirements

You will need the following:

  1. The directory containing the raw files
  2. The Relay port (ami.port=3289 by default)
  3. Telnet

Configuration

Like the Center and Web, the Relay has an optional resources directory. This can be set by the user via local.properties:

ami.relay.plugins.resource.root.dir=<path/to/dir>
ami.port=<your_port_number> # if not using the default value

Note

This is the same directory that the Replay command uses.

LoadFile Command Syntax

LoadFile commands use the following syntax:

V|T="LoadFile"|LOGIN="<identifier>"|FILE="<target_file>"|COLUMNS="<comma_delimited_list_of_columns>"|CLASSES="<comma_delimited_list_of_column_types>"

Additional optional parameters can be added in a pipe-delimited list. See the table below for a description of each parameter.

Parameter Description Example
V|T="LoadFile" Sets command to LoadFile V|T="LoadFile"
LOGIN String identifier for the process calling the command LOGIN="user"
FILE Name of the file to read FILE="AAPL.csv"
COLUMNS Name of the data columns in a comma-delimited list COLUMNS="Date,Open,High,Low"
CLASSES Data type classes corresponding to the columns CLASSES="String,Double,Double,Double"
MPS (Optional) Maximum number of lines per second read from the file MPS=10
NULL (Optional) Value that if found should be treated as null (default is null) NULL="null"
QUOTES (Optional) Character value if found should be treated as quotes (e.g: #123# becomes 123 if # is the quote character) QUOTES="#"
LIMIT (Optional) The maximum number of lines to be read from the file, by default this is the Java Long type's maximum value LIMIT=10
SKIP (Optional) The number of lines from the beginning of the file to skip, by default this is 0 SKIP=1
DELIM (Optional) The character or characters to delimit rows by, by default this is , DELIM="."
TYPE (Optional) The name of the Table created in the Center, this defaults to "FILE:" TYPE="AAPL"

Note

If your Relay resources directory has subdirectories, ensure the relative path is expressed in the FILE parameter. E.g: FILE="file/AAPL.csv".

LoadFile Command Quickstart Guide

  1. Ensure that the Relay is correctly configured and running. Telnet into the platform's real-time streaming port (ami.port).

  2. Have a file containing tabular data in the Relay resources directory, e.g AAPL.csv:

    Date,Open,High,Low
    2025-01-02,187.45,189.12,186.78
    2025-01-03,188.10,190.05,187.60
    2025-01-06,189.75,191.20,188.90
    2025-01-07,190.30,192.10,189.55
    2025-01-08,191.80,193.45,190.70
    2025-01-09,192.25,194.00,191.50
    2025-01-10,193.60,195.10,192.80
    2025-01-13,194.20,196.30,193.75
    2025-01-14,195.50,197.00,194.60
    2025-01-15,196.10,198.25,195.30
    2025-01-16,197.40,199.10,196.55
    2025-01-17,198.00,200.20,197.25
    2025-01-21,199.30,201.00,198.50
    2025-01-22,200.10,202.35,199.20
    2025-01-23,201.50,203.10,200.75
    2025-01-24,202.20,204.00,201.40
    2025-01-27,203.75,205.50,202.90
    2025-01-28,204.10,206.20,203.30
    2025-01-29,205.60,207.15,204.80
    2025-01-30,206.25,208.40,205.50
    
  3. Run the LoadFile command setting the LOGIN field to a string to identify your process, e.g "demo", and configure the remaining parameters according to your data:

    V|T="LoadFile"|LOGIN="demo"|FILE="file/AAPL.csv"|COLUMNS="Date,Open,High,Low"|CLASSES="String,Double,Double,Double"|SKIP=1|TYPE="aaplPrices" 
    

    If successful, you should receive a series of messages acknowledging and sending the data to the Center:

    1
    2
    3
    4
    5
    M@1771952958174|Q=1|S=1|M="Sent 21 record(s) from file: file/AAPL.csv" 
    M@1771952958174|Q=2|S=0|M="OK, object accepted"
    M@1771952958174|Q=3|S=0|M="OK, object accepted"
    ... 
    M@1771952958175|Q=22|S=0|M="OK, object accepted"
    

    Note

    Each message corresponds to a row of data.

  4. View the data in the table by running SELECT * in the Center's AMIDB shell tool:

    SELECT * FROM aaplPrices 
    

    This will output the following: