Skip navigation
Contact Us
11441 Views 19 Replies Latest reply: Oct 21, 2013 4:17 AM by Shirish Ganta RSS
Joseph . Novice 56 posts since
May 4, 2011
Currently Being Moderated

Jul 21, 2011 12:43 PM

Target Flat file name with timestamp

Hi Experts,

 

I hope this question might be answered before, but i couldnt find it right now so posting this again. I need this urgently.

 

I have a mapping whose target is flat file and the naming convention is XXXYYY_TIMESTAMP.DAT. Need to know how ot capture the timestamp part in the target file name.

 

Appreciated your answer!

 

Thanks.

  • Veeru B Master 1,242 posts since
    Sep 27, 2010
    Currently Being Moderated
    Jul 21, 2011 12:56 PM (in response to Joseph .)
    Re: Target Flat file name with timestamp

    Hi Josef,

     

    We can achive this by using Unix script. After completion of session run the following script to rename target file with date. if you want you can change date to time stamp

     

    Try this

     

     

    ##Script used to rename file to add time stamp
    #######################################################################

     

    DATE=`date +%Y%m%d`

     

    mv target.txt targetpath/XXXXYYY_$DATE.DAT

     

    Regards,

    Veeru

      • Veeru B Master 1,242 posts since
        Sep 27, 2010
        Currently Being Moderated
        Jul 21, 2011 8:40 PM (in response to Joseph .)
        Target Flat file name with timestamp

        Josef,

         

        Yuo can achive second one in two ways. One through mapping and second one through scripting.

         

        Easy one is scripting . For header as column names you can use informatica opting if you are using 8 informatica version. This property available in session level target properties.

         

        Regards,

        Veeru

  • Deepak N Novice 37 posts since
    May 19, 2011
    Currently Being Moderated
    Jul 21, 2011 10:06 PM (in response to Joseph .)
    Re: Target Flat file name with timestamp

    Hi Josef,

     

    If you are using Informatica 8.x you can create target file name dynamically. In target designer there is an option to add file name port to the target. You can define your target file name in that port.

     

    Follow below steps to create filename port in target,

    1) Goto Target double click on it to open Edit Table window.

    2) Goto Columns Tab - > Click on 'F' icon which is located next to New/delete/copy ports icons

    3) New FileName Port will be added to the target

    4) Now in Expression transformation create a output port for o_FileName and map it to target filename port.

     

    target_filename_port.JPG

     

     

    Thanks,

    Deepak NBK.

    • Satish jampa Newbie 15 posts since
      Jan 18, 2012
      Currently Being Moderated
      Jan 19, 2012 8:41 AM (in response to Deepak N)
      Target Flat file name with timestamp

      Hi Deepak,

       

      I'm new to informatica and im trying to load 2 tables into a another table 

      src_Tbl_1: sno,name,add

      src_Tbl_2:Src_Name --returns only 1 value 'TestDB'

      these two tables have no relation at all cannot join , the final target table should look like

      tgt_Tbl_3: Sno,name,add, Src_name,Dateinserted.(cannot hardcode the SRC_NAME in the target)

      is there a way we can achieve this .

       

      thanks in advance!!

      • Mahaveer Singh Novice 33 posts since
        Jan 11, 2012
        Currently Being Moderated
        Nov 27, 2012 11:52 AM (in response to Satish jampa)
        Target Flat file name with timestamp

        Hi Satish,

         

        I suggest we go for a trick to join the two tables having no column in common using the sequence generator. As i did, before joining the two create a port say 'SEQ1' and 'SEQ2' in the two sources and let the Seq. generator populate the column. Now we have a common column 'SEQ1' and SEQ2 to give in Joiner transfomration and to load the output.

         

        Hope this resolves.

         

        Regards,

        Mahvaeer.

      • azhar ahamad Newbie 3 posts since
        Nov 15, 2012
        Currently Being Moderated
        Nov 27, 2012 3:13 PM (in response to Satish jampa)
        Target Flat file name with timestamp

        Satish ,

         

        Does the 2nd table return only 1 value for all rows or has only 1 record ?

         

        Sequence generator will generate a new number for each record, so, even if you use sequence generator, you might miss some records.

         

        Have the 1st table new column and name it "key" - 1 and second table "key" - 1 , so this will give multiple matches, and you can get all records, with the same value.

         

        hope this helps.

         

        -Azhar.

  • mayur marathe Newbie 9 posts since
    Oct 15, 2013
    Currently Being Moderated
    Oct 20, 2013 10:36 PM (in response to Joseph .)
    Target Flat file name with timestamp

    Hi My Scenario is little different , i have source file as .dat file and i have to create .dat file as a target (output) from that file with the name "timestamp_source.dat"

    source = test_20131008.DAT

    output = 20131008.DAT

     

    please provide details steps or idea as i am new to informatica, it is urgent

    

    • Shirish Ganta Master 1,141 posts since
      Feb 17, 2013
      Currently Being Moderated
      Oct 20, 2013 11:00 PM (in response to mayur marathe)
      Target Flat file name with timestamp

      Hi Mayur,

       

      Could you please elaborate bit more on your requirement ?

       

      You just want dynamic target file name or you want informatica to read dynamic source file name also ?

       

      If it just a taget file name and that too target file name is the part after "_". Than configure your source to have Currentlyprocessedfilename port.

       

      With that read the file name and in expression use the below code to get the source file name with out path.

       

      var_FILENAME=SUBSTR ( CurrentlyProcessedFileName , INSTR (  CurrentlyProcessedFileName ,  '/'  ,  - 1, 1 )+1 )

       

      Than use SUBSTR(var_FILENAME,INSTR(var_FILENAME,'_')+1) will give you the target file name.

       

      Add filename port also in target and connect it.

       

      This you can do using assignment also but assignment will be based on sysdate..if you want to process some old files you need to modify the code.But using the above process you can process any thing.

       

      For dynamic source read you can use indirect and create list using ls test_*>src_list.txt

       

      and use the src_list.txt as your indirect file.

       

      Regards

      Shirish

      • mayur marathe Newbie 9 posts since
        Oct 15, 2013
        Currently Being Moderated
        Oct 21, 2013 2:20 AM (in response to Shirish Ganta)
        Target Flat file name with timestamp

        HI Shirish

         

        Thanks For reply .

         

        I have a source as dat  file and i have to create output  file as .dat file means when i run the mappind it should give me the flat file as output , and the name should contain the timestamp of source file.the Filename you have already told but how to create a file from mapping itself by filename port , i want that port , as i am new i want the steps to follow i have added the source in the mapping and filter but stuck in the mapping to create file

         

        Any help , will be really appreciable

         

        regards

        mayur

        • Shirish Ganta Master 1,141 posts since
          Feb 17, 2013
          Currently Being Moderated
          Oct 21, 2013 2:29 AM (in response to mayur marathe)
          Target Flat file name with timestamp

          Hi Mayur,

           

          Open your Target flat file defination in Target designer. Double click on it it open the edit window, go to Columns tab..there top right corner you can see icon "F" surrond with dotted square click on that it will add file name port in the column section (You should not add file name port manually it wont work).

           

          Using the source file name derive the target file name as explained in the above post and connect to this port. In the session properties you define any name in target it doesnot matter...but make a note in your target file directory there will be two files one is with zero byte file with the name you mentioned in target properties and second with with the derived target name with actual data.

           

          Please let me know if you need further info in this regard.

           

          Regards

          Shirish

          • mayur marathe Newbie 9 posts since
            Oct 15, 2013
            Currently Being Moderated
            Oct 21, 2013 2:42 AM (in response to Shirish Ganta)
            Target Flat file name with timestamp

            hi Ashish

             

            Thanks for Reply once again

             

            I guess i am not asking the question correctly

             

            your told in earlier post to open a file in target analyzer , but i dont have file physically present on my machine to open and use in the target window  , I have to create the file as output the flow of mapping  will be as

             

            source file - > Filters -> transformation - > and then the File creation at the end of mapping

             

            Sorry for troubling you

             

            Regards

            Mayur

            • Shirish Ganta Master 1,141 posts since
              Feb 17, 2013
              Currently Being Moderated
              Oct 21, 2013 2:49 AM (in response to mayur marathe)
              Target Flat file name with timestamp

              Hi Mayur,

               

              You have to create Target defination dear, i mean how you want your target to be populated and what are columns needed etc. This is just a defination not a physical file. When you connect the respective ports from source to target columns...Informatica create a physical file with the columns connected in mapping.

               

              So first create target defination and than proceed as i mentioned in my above posts.

               

              Regards

              Shirish

More Like This

  • Retrieving data ...

Bookmarked By (1)