How to Load a Flat File into an Empty Table with Teradata TPT: A Simple Example

This article illustrates loading a flat file into an empty Teradata table using TPT. The example was successfully tested on Teradata 16.20.

Although TPT does offer a wide range of advanced options for loading files, it can be overwhelming for basic tasks. In this demonstration, I will present a simplified approach to loading flat files with any number of columns and a selectable separator into a Teradata target table.

We assume that the target table is present and empty.

CREATE TABLE DWHPRO.FlatFile
(
	ColA CHAR(10),
	ColB CHAR(10)
) PRIMARY INDEX (ColA);

Here is a TPT script example. Define the TargetTable parameter, which corresponds to the $INSERT template. The parameter file provides details about the flat file to the $FILE_READER template. Additionally, the parameter file includes the logon definition.

/* Parameter file dwhprovars.txt */
/********************************************************/
/* TPT LOAD Operator setting                            */
/********************************************************/
 LoadTdpId                  = '127.0.0.1'
,LoadUserName               = 'tuning'
,LoadUserPassword           = '********'
,LoadPrivateLogName         = 'LOAD_OPERATOR_LOG'
,LoadTraceLevel             = 'None'

/********************************************************/
/* TPT DataConnector Producer Operator setting          */
/********************************************************/
,FileReaderFileName         = 'dwhpro.txt'
,FileReaderFormat           = 'Delimited'
,FileReaderOpenmode         = 'Read'
,FileReaderDirectoryPath    = './'
,FileReaderTextDelimiter    = ';'
,FileReaderPrivateLogName   = 'FILE_READER_LOG'
/* Script SimpleFlatFile */
DEFINE JOB FlatFile
DESCRIPTION 'Load a flat file'
(

  SET TargetTable = 'FlatFile';
  SET LogTable = @TargetTable || '_LOG';

  STEP MAIN_STEP
  (
    APPLY $INSERT TO OPERATOR ( $LOAD [1] )
    SELECT * FROM OPERATOR ( $FILE_READER [1] );
  );
);

Using Fastload, we can load any flat file that has a separator. The FileReaderTextDelimiter can define the separator. In our case, we use “;” instead of the default pipe character that TPT expects. The file we use as an example is shown below.

a;b
c;d
e;f

tbuild -f SimpleFlatFile -v dwhprovars.txt -j dwhpro

TPTLoad

TPT templates simplify tasks in TPT by eliminating the need for complex scripts. TPT automatically switches from Fastload to Multiload if the target table is not empty, but this feature is not available in our example with templates. As a result, users must delete all rows beforehand.

What are TPT Templates?

TPT templates are the textual definition of operators and can be included easily, as shown above. For example, $FILE_READER defines a DATACONNECTOR PRODUCER operator. The templates can be found in the following path in the Linux file system:

/opt/teradata/client/16.20/tbuild/template

Related Services

🔧 Need Expert Database Administration?

Our team brings 25+ years of enterprise DBA experience across Teradata, Snowflake, and Oracle.

Meet Our Team →

📖 Go Deeper: Teradata Performance Tuning

The definitive guide used by data engineers worldwide. Practical techniques, real examples, proven results.

About the Book →

📊 Data Platform Migration Survey

Help us map where the industry is heading. Results are public — see what others chose.

1. What is your current data platform?

2. Where are you migrating to (or evaluating)?

Migrating FROM
Migrating TO

Thanks for voting! Share this with your network.

Follow me on LinkedIn for daily insights on data warehousing and platform migrations.

Stay Ahead in Data Warehousing

Get expert insights on Teradata, Snowflake, BigQuery, Databricks, Microsoft Fabric, and modern data architecture — delivered to your inbox.

Leave a Comment

DWHPro

Expert network for enterprise data platforms. Senior consultants, project teams built for your challenge — across Teradata, Snowflake, Databricks, and more.

📍Vienna, Austria & Miami, Florida

Quick Links
Services Team Teradata Book Blog Contact Us
Connect
LinkedIn → [email protected]
Newsletter

Join 4,000+ data professionals.
Weekly insights on Teradata, Snowflake & data architecture.