6 Replies Latest reply on Jun 9, 2014 9:26 PM by janakiram.dabbara@itcinfotech.com

    Create a single mapping for different types of flat files

    New Member

      Dear Experts,

      Scenario: I have two flat files which contains same columns but the types of file is diferent it may be change, i want to achieve this using single mapping

      sample1.text

      col1,col2,col3

      a,b,c

      d,e,f

       

      sample2,txt

      col1  col2  col3

      g  h  i

      j  k  l

      Tgt

      col1, col2,col3

      a,b,c

      d,e,f

      g,h,i

      j,k,l

       

      Please help me thanks

        • 1. Create a single mapping for different types of flat files
          Rahul Yadav Active Member

          Hi,

          use seperate source qualifier and import the two files take one expression and she pass all the ports from source and then. import target with 1 more target instance.

          connect source 1 ports to target 1 and source2 ports to target instance

          hope this will help you

           

          thanks rahul

          • 2. Create a single mapping for different types of flat files
            Guru

            Hi,

             

            You can do this in the following ways:

             

            1. At Session level, change Source FileType as INDIRECT and call these source file names inside a .txt file
            2. You can create a seperate session and call mention the second source file at session level in it.

             

             

            Let me know if this helps.

             

            Also mark the answer as helpful / anwered so that this can help others.

             

            Cheers,

            Chanda

            • 3. Create a single mapping for different types of flat files
              New Member

              Dear All,

              Thanks for your quick response....

              Rahul solution is working fine but i am little bit confuse with CHANDA solution because both the files containing data in different format, sample2 file (col2,col3) data is not loading into the target.

               

              I just wanted to ask one thing, can we develop a mapping which contains same columns but we dont know format type like (comma separated, tab, space, quotes etc)

               

              Thanks for your valuable feedback

              • 4. Create a single mapping for different types of flat files
                Guru

                Hi,

                 

                From your example, I understood that you are having same number of columns. But I did not know that the Dimiliter  - comma seperated, space, etc, is the challenge.

                 

                Just want to let you know that we need to know the format type of the source file i.e. when we import the source file definition, we need to define the DELIMITER as well.

                 

                It is not possible to dynamically decide this.

                 

                Let me know if this helps.

                 

                Cheers,

                Chanda

                • 5. Create a single mapping for different types of flat files
                  Rahul Yadav Active Member

                  Hi meena,

                   

                   

                  As per my knowledge we cannot handle delimiter dynamically.

                   

                   

                  But we have one option to handle multiple delimiter.

                   

                   

                  If you know the types of delimiter coming from flat file then you can specify in flat file properties.

                   

                   

                  Steps to follow for this solution:

                   

                   

                  1:open flat file SRC in powercenter designer, double click on it.

                  2:goto advanced file properties

                  3: In column delimiter, list all the delimiters.

                  4:uncheck the property "Treat multiple delimiter as AND unchecked"

                   

                   

                  Hope this will help you.

                   

                   

                  Thnaks

                  Rahul

                  • 6. Create a single mapping for different types of flat files
                    Guru

                    Hi Meena,

                     

                    Try like below if ur OS in Linux/Unix

                     

                    for changing the delimeter during the session run

                     

                    in Sesion pre-session Success command i have used the sed command for changing the delimeter as

                     

                    Here source file am getting delimeter as Comma(,) and the mapping i have created with Pipe(|).

                    in pre session i have used the below script for changing delimeter.


                    cd <Dir Path>;

                    chmod 777 J_Scenario_53.txt;

                    sed -i 's/,/|/g' J_Scenario_53.txt;

                     

                    and if we want to change the delimeter back to Comma(,). just change the script in sed command and used in post-session successed command as

                     

                    cd <Dir Path>;

                    chmod 777 J_Scenario_53.txt;

                    sed -i 's/|/,/g' J_Scenario_53.txt;

                     

                    Now in server the file is with the original Delimeter comma(,).

                     

                     

                    i hope this can be helpfull