Pages

Thursday, March 14, 2013

How to load the data from a flat file into the target where the source flat file name changes daily?


Example: I want to load the customers data into the target file on a daily basis. The source file name is in the format customers_yyyymmdd.dat. How to load the data where the filename varies daily?

The solution to this kind of problems is using the parameters. You can specify session parameters for both the source and target flat files. Then create a parameter file and assign the flat file names to the parameters.

Specifying Parameters for File Names:

The steps involved in parameterizing the file names are:
  • Creating the Parameter File
  • Specifying the parameters in Session
  • Specifying the parameter file name

Creating Parameter File:

Assume two session parameters $InputFileName and $OutputFileName for specifying the source and target flat file names respectively. Now create a parameter file in the below format

> cat dynamic_file_names.param
[FolderName.SessionName]

$InputFileName=customers_20120101.dat

$outputFileName=customers_file.dat

Specifying Parameters in Session:

Now you have to specify the parameters in the session. Edit the session and go to the Mapping tab. In the mapping tab, select the source qualifier in the Sources folder and set the file property "Source FileName" as $InputFileName. Similarly, for target file set the "Source FileName" as $OutputFileName.

Specifying Parameter File Name:

The last step is specifying the parameter file name. You can specify the parameter file name either in the session level or workflow level. To specify in the session level, go the properties tab of the session and set the property "Parameter FileName".

To specify the parameter file at workflow level, click on the "Worfklows" in toolbar and then on Edit. Now go to the properties and set the file property "Parameter FileName"

Thats it you are done with using the parameters as filenames. Now you have to take care of changing the file name in the parameter file daily.

Note: You can even specify the source and target directories as parameters.

No comments:

Post a Comment