How to fix the length of the output file

hi,
I have 1000 records in my source table which need to be inserted into file. But the length of the rows in my file should be only 500 i.e there should be two files getting created for this 1000 records i.e my each output file should contain only 500 rows not more than that.
Depending on the number of records present in the source, the file getting created will be varying as my file should contain only 500 rows each. for ex: if 5000 rows are present then 10 files need to be created.
How this can be achieved in ODI.
Thanks in advance

I believe this can achieved using jython easily .
Here is a sample output code
Command on Source - Select database Technology and required logical schema
Command on Target - Jython
import java.sql as sql
import java.io as io
import string,re
import java.lang as lang
import java.text as text
myCon = odiRef.getJDBCConnection("SRC")
myStmt = myCon.createStatement()
my_query="SELECT * FROM  SCHEMA.TABLE_NAME "
file_count=1
i=1
myRs = myStmt.executeQuery(my_query)
writer=io.BufferedWriter(io.OutputStreamWriter(io.FileOutputStream('c:\\FILE_'+str(file_count)+'.csv')))
md=myRs.getMetaData()
collect=[]
while (i<= md.getColumnCount()):
    collect.append(md.getColumnName(i))
    i+=1
header=','.join(map(string.strip,collect))
#writer.write(header+'\n')
myRs = myStmt.executeQuery(my_query)
md=myRs.getMetaData()
myRs.setFetchSize(5000)
i=0
while (myRs.next()):
    j=1
    col=[]
    while (j<= md.getColumnCount()):
        col_type=md.getColumnTypeName(j)
        col_name = myRs.getString(md.getColumnName(j))
        if col_name is None:
            col_name= ''
        col.append(col_name)
        j+= 1
    data=','.join(map(string.strip,col))
    writer.write(data+'\n')
    #print data+ '\n'
    i +=1
    if (i == 500):
        writer.flush()
        writer.close()
        file_count +=1
        writer=io.BufferedWriter(io.OutputStreamWriter(io.FileOutputStream('c:\\FILE_'+str(file_count)+'.csv')))
        i=0
writer.flush()
writer.close()
myCon.close()Please run this code and let me know if you need any other help or modification to get your desired results.

Similar Messages

  • How to fix the .pdf file with error "invalid annotation object"

    how to fix the .pdf file with error "invalid annotation object"

    As long as the PDF opens, then just try saving it to a new file name. There may be a preflight script that would help troubleshoot the issue.

  • How to get the Output File Name as One of the Field Value From Payload

    Hi All,
    I want to get the Output file name as one of the Field value from payload.
    Example:
    Source XML
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_TEST xmlns:ns0="http://sample.com">
    - <Header>
      <NAME>Bopanna</NAME>
      </Header>
      </ns0:MT_TEST>
    I want to get the Output file name as " Bopanna.xml"
    Please suggest me on this.
    Regards
    Bopanna

    Hi,
    There are couple of links already available for this. Just for info see the below details,
    The Output file name could be used from the field value of payload. For this you need to use the UDF DynamicFile name with below code,
    //       Description: Function to create dynamic Filename
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    With this udf map it with the MessageType as
    (File Name field from Payload) > DynamicFileConfiguration>MTReceiver
    Thanks
    Swarup

  • How to fix the output length of a field

    Hi!
    I want to 'allocate' the full length of the field while smartform printing even if it is initial.
    How can I do this? I tried the &field(*)& &field(F<' '>)& output format, but nothing.
    Thanks

    Hi!
    I have only one text element, and in that I have two variables separated only with one space. In the printed form the starting place of the second variable depends on the length of value in the first variable.
    like this:
    The first variable has the dictionay type 'VBELN', despite this fact, the &FIELD(*)& does not work.
    The template doesn't work here too. because I have only one text element.
    Or can I print two text element in one row? It could be a solution probably.

  • How to Fix the row in sap script, its urgent......

    Hi Experts,
    first i explain my sap script, i have print void check in my script client give readymade format means box are there, lines are there. i have to fix in box and line data form database table. everthing is working fine. i got all data. i have total 6 window in my script .but i have one issue  In my sap script in header window total five rows... like below
    Check voucher no:8888
    check No: 1234
    Date:1/28/2007
    Bank:xyz
    Batch no: 5678
    now sometime check voucher is balnk....
    Check voucher no: BLANK/NULL
    check No: 1234
    Date:1/28/2007
    Bank:xyz
    Batch no: 5678
    because of that all rows are move up side and all window also move up side and so script not fix to the box and line all data are seen not perfectly... so guru`s how to fix the row and window in script....
    its urgent...
    Waiting for ur reply
    Thanks & regards
    Jigar

    Hi,
    Follow the below steps . Definately your issue will bve resolved.
    Let us suppose you are printing following fields
    PH &v_text&
    PH &v_text1&
    PH &v_text2&
    you will get the output as you expected.
    and if you have any conditions  for these fileds
    /: if v_text is not initial.
    PH &v_text&
    /: endif
    PH &v_text1&
    PH &v_text2&
    if you have data in each field then you will get output as expected .
    But when v_text is initial.
    the data will be moved up wnhich is happening in your case.
    so what you need to do is?
    /: if v_text is not initial.
    PH &v_text&
    /: else
    PH  (Here you need to mention empty line with same paragraph format
    /: endif.
    PH &v_text1&
    PH &v_text2&
    Reward points if useful
    Regards,
    Nageswar

  • How to fix the BitRate & FrameRate

    hi all.
    I met a problem, how to fix the BitRate and FrameRate when sent by transmitter to the network using RTP protocol, and received by receiver at the same BitRate and FrameRate? Is there a mechanism in JMF to update the BitRate and FrameRate using the RTCP protocol?
    thanks.

    hi all.
    after creating the processor for the input datasource from a camera, i use following codes to set the framerate for the processor:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    FrameRateControl fr=(FrameRateControl)processor.getControl("javax.media.control.FrameRateControl");
    BitRateControl br=(BitRateControl) processor.getControl("javax.media.control.BitRateControl");
    br.setBitRate(1000000);
    System.out.println("frame rate= "+fr.setFrameRate(30)+"fps");
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    the output is:
    ~~~~~~~~~~~~~~~~~
    frame rate= -1.0fps
    ~~~~~~~~~~~~~~~~~
    according to the API documents of JMF2.1.1e, this output means "Returns -1 if it is unknown or it is not controllable".
    what should do to set the framerate for the processor? many thanks.

  • I am unable to hear anything on my iphone 4 nor can the person i call hear anything when i speak - I think that my ear piece and mike have both got magnetised how do fix the problem

    I am unable to hear anything on my iphone 4 nor can the person i call hear anything when i speak -
    I think that my ear piece and mike have both got magnetised how do fix the problem
    Please help

    I have the same problem!! It lead to many other problems with my phone
    I just arranged a repair with apple. Yes its inconvenient to be without a phone for a while but if your phone is in warranty its good to get it looked at professionally!

  • I have 4s iPhone , I download the iOS 7. Now the front receiver microphone is not working , please help me that how to fix the problem.

    I have 4s iPhone , I download the iOS 7. Now the front receiver microphone is not working , please help me that how to fix the problem.

    I live in South Africa, and I had the same problem with my iPhone 4.
    After weeks of frustration and swearing, I was in the process of restoring my phone to a previous iOS. To do that you need to turn the "Find my iPhone" option off, since i turned it off, my problem was solved. No need to repair anything or revert back to old iOS.
    ***** that i cant use Find my iPhone, but atleast i can use my phone.

  • How to store the output of a analog to digital converter into an 2D array

    Hi
    I am doing my M.Tech Thesis in Image reconstruction and I am using labview for simulation and I want to know how to store the output of a analog to digital converter into an 2D labview array.

    nitinkajay wrote:
    I want to know how to store the output of a analog to digital converter into an 2D labview array.
    How exactly are you performing 'Analog to Digital'???
    Grabbing image using camera OR performing data acquisition using DAQ card OR some other way????
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to download the output of a report along with column header

    Hi,
    Could someone please tell me on how to download the output of a report along with column header to .txt format. A download option needs to be given to the user using physical and logical file names .The report basically contains header details and item details and requirement is to download the same format into an .txt format.

    Hello,
    Try this FM:
    Data: being of itab occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    end of itab.
    data:begin of fld_tab occurs 0,
    fld_name(20),
    end of fld_tab.
    fld_tab = 'Material'.
    append fld_tab.
    fld_tab = 'Material Desc'.
    append fld_tab.
    CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
            BIN_FILESIZE            = ' '
            CODEPAGE                = ' '
             FILENAME                = 'C:\1.txt '
             FILETYPE                = 'DAT'
            MODE                    = ' '
            WK1_N_FORMAT            = ' '
            WK1_N_SIZE              = ' '
            WK1_T_FORMAT            = ' '
            WK1_T_SIZE              = ' '
            COL_SELECT              = ' '
            COL_SELECTMASK          = ' '
            NO_AUTH_CHECK           = ' '
       IMPORTING
            FILELENGTH              =
         TABLES
              DATA_TAB                = itab
              FIELDNAMES              = fld_tab
       EXCEPTIONS
            FILE_OPEN_ERROR         = 1
            FILE_WRITE_ERROR        = 2
            INVALID_FILESIZE        = 3
            INVALID_TYPE            = 4
            NO_BATCH                = 5
            UNKNOWN_ERROR           = 6
            INVALID_TABLE_WIDTH     = 7
            GUI_REFUSE_FILETRANSFER = 8
            CUSTOMER_ERROR          = 9
            OTHERS                  = 10
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Naimesh

  • How to save the output of a concurrent proram automatically

    Hi Friends,
    We have a requirement to save the output of a concurrent program to a specific folder for a reporting purpose. whenever we run that concurrent program it should save the out file in the network folder \\out_files\con_prg like that
    instead of storing it in its default folder in unix.(or I should recoganize which out file is for my concurrent program from the default folder and to move it to windows shared network folder). If it is one time , I can do it manually. But I need to schedule that concurrent program to run every day and transfer the output to the windows folder.
    Our system is Oracle Apps 11i , Data base 9i in Solaris.
    If you have any idea or sugesstion for this , please share it with me here.
    Thanks in advance,
    Vimal...

    Hi
    Thanks for the reply. I can get the name from the fnd_concurrent_requests table, But how can I identify which is the one submitted by me. Because there is possibility of multiple submission by the users with different parameters.
    I can give you more details.
    We are having a BI report (not oracle) for AR Aging Report details. It has a staging table to get the data from Oracle EBS.
    My job is to run Our Customized AR Aging Report with 2 different parameters like sysdate and the same date for last month.
    Get the output file and processs it (for this we are using VB Script) to populate the staging table from where the BI report get the data.
    So far I am doing this manually for more than a month.
    The Users wants to have all the above mentioned process to be combined as a single concurrent program , so that they can submit easily and populate the data any time of the day like other Oracle Standard reports.
    The BI report can be viewed any time of the day by more than 15 users and also AR Aging report can be run so many times in a day by another set of users.
    In this situation how can I get the exact output file of the request submitted by me.
    Thanks,
    Vimal...

  • How to use the Output clause for the updated statment

    How to use the output clause for the below update stament,
    DECLARE @MyTableVar table(
        sname int NOT NULL)
    update A set stat ='USED' 
    from (select top 1 * from #A 
    where stat='AVAILABLE' order by sno)A
    Output inserted.sname
    INTO @MyTableVar;
    SELECT sname
    FROM @MyTableVar;
    Here am getting one error incorrect syntax near Output
    i want to return the updated value from output clause

    see
    http://blogs.msdn.com/b/sqltips/archive/2005/06/13/output-clause.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to Delete the Photo's in iPad1 , how to fix the simcard for iPad with 3G....

    hello..
                  How i can delete the photos which are uploaded in ipad .
    How to fix the sim card in the 3G iPad, where i can get the tool which to open the simcard slot.

    How i can delete the photos which are uploaded in ipad .
    If they are photos you synced from iTunes, they are removed in the same manner... unsync them, i.e. deselct them from syncing.
    How to fix the sim card in the 3G iPad, where i can get the tool which to open the simcard slot.
    The tool should have come with the iPad...

  • How to change the output as text format in Apps R12.1.3

    Hi All,
    Currently iam trying to modify the Java Concurrent Program (FDExtractAndFormatting) in Batch Payment Process. This Program is generated in text format in 11i APPS. Now we are upgrading to R12.1.3. In R12.1.3 output is coming as PDF format. Here my requirement is how to change the output as text format in R12.1.3 also.
    Please do the needful and suggest me.
    Regards,
    Jagadeesh

    1. It is seeded java concurrent program. Some attributes are missing from 11i to R12. In 11i it is a text format.So i have to investgate on how to retrive those attributes in R12. What is the concurrent program name?
    Have you tried to change the output and submit the request?
    2. Once all are attributes are coming in PDF format. Client wants to open same output in text format as it is 11i (In R12 it is generated in PDF format).If the above does not help, please log a SR.
    Thanks,
    Hussein

  • Within redbox I can not click on a movie and get information about it, instead I get an error message that says that the situation may be temporary. yet i keep having the same problem. Do you have any idea how to fix the problem?

    Within redbox I can not click on a movie and get information about it, instead I get an error message that says that the situation may be temporary. yet i keep having the same problem. Do you have any idea how to fix the problem?

    Did you delete all receipts with iDVD in the file name  with either a .PKG or .BOM extension that reside in the HD/Library/Receipts folder and from the /var/db/receipts/  folder before installing the new copy?  If not then do so and delete the new application also.
    Click to view full size
    Then install iPhoto from the disk it came on originally and apply all necessary updaters: Apple - Support - Downloads
    OT

  • I have 100  songs on i pod touch. But when i connect it to itunes it only showed 44 songs. What is actually happening and how to fix the problem so that all music in my iphone can be seen in my itunes

    I have 100  songs on i pod touch. But when i connect it to itunes it only showed 44 songs. What is actually happening and how to fix the problem so that all music in my iphone can be seen in my itune

    If they are iTunes purchased music then go to Settings>iTunes and App Store and turn off Show All.
    Next
    Try:
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync/delete all music and resync
    To delete all music go to Settings>General>Usage>Storage>Music>Tap edit in upper right and then tap the minus sign by All Music
    - Reset all settings                            
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes
    - Restore to factory settings/new iOS device.                       

Maybe you are looking for