Skip to main content

Data & Intelligence

Informatica: Dynamic Source File Name

 

Scenario: Data source is a flat file and we want to load this data into the target. The problem is the source file name keeps on changing.

 Here we go:

  1. Use a pre-session script that creates a file list.

Windows

Data Intelligence - The Future of Big Data
The Future of Big Data

With some guidance, you can craft a data platform that is right for your organization’s needs and gets the most return from your data capital.

Get the Guide

dir /b part_of_file_name*.txt > FILELIST_NAME.LST

UNIX

ls part_of_file_name* > FILELIST_NAME.LST

             01

 

  1. In Workflow Manager edits the session task and go to the Mapping tab.
  2. Select the flat file source.
  3. Under Properties, enter the list file name (“FILELIST.LST”).

Under Source filename change the value for Source file type to Indirect.

             02

Thoughts on “Informatica: Dynamic Source File Name”

  1. I found an alternative Informatica offical website: It uses a wildcard in the name of a source file in a PowerCenter session, use the Command option:
    In the Workflow Manager, edit the session task and go to the Mappings tab.
    Select the Flat File Source Definition and click the Properties tab.
    Set the Input type as “Command” and the Command type as “Command generating File list”.
    In the Command option, enter the command to list the files.
    The Command used depends on the operating system.

    Windows
    On Windows, due to a known issue, the command will need to be added to a batch file.

    Example
    The following commands can be added to a batch file to list the files in “bare” mode:
    @echo off
    cd C:\Informatica\PowerCenter8.6.1\server\infa_shared\SrcFiles
    dir /b file_name*.txt
    In this case the batch file is called file_list_test.bat.
    The following would be added to the command option:
    $PMSourceFileDir\file_list_test.bat

    UNIX
    On UNIX, use the ls command in the Command option.

    Example
    ls $PMSourceFileDir/file_name*
    These commands generate a file list from the source file directory of all files that start with the same name.
    When the session runs, the flat file reader reads each file as it reads the file names from the command.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.