How to load multiple files into one single Table using TPT in Teradata?
We recently received a comment on our previous TPT post,(Click here to read it) requesting for a sample TPT script to load multiple data files into one single Teradata Table using Load operator.The TPT script is simple and is very much similar to our TPT script we shared in earlier posts. The main component which will change is the PRODUCER operator. Here we’ll use 2 new variables :
VARCHAR FileList = ‘YES’,
VARCHAR FileName = @File1
FileList : represent here that we are going to process list of files.
FileName: the Filename which has list of DATA files in it. One in each line.
So we will have following 6 files for this example:
- TPT_Name_LOAD.tpt: This is the main TPT file which will hold code to load DATA FILES into TARGET table.
- TPT_Variables.txt: This is the variable file in which we will define all the parameters used in TPT script.
- FILELIST.TXT: This is the file which will hold name of all the DATA FILES in it.
- emp.csv: First Data File.
- emp1.csv: Second Data File.
- emp2.csv: Third Data File.
Let us see now content of each file:
Place all the 6 files in a directory and run below command:
tbuild -f TPT_Name_LOAD.tpt -v TPT_Variables.txt
Note: Each of the 3 Data Files have 1 record only.
Once the script executes successfully run below command in Teradata:
SELECT * from EMP_NAME;
Output should be 3 rows one from each file.