How to extract a part of text using utl_file

hi,
I have a small requirement which goes as follows. I have a text file which is a resultof the sql query and it contains 16 columns as TAB delimited text . I am using the UTL_FILE package concept to read the data. In general when we use the UTL_FILE.GET_LINE we read the entire line of text. But i need to read the 10th column of the query or the tab delimited text .
Please advice.
My query goes something like this:
declare
f utl_file.file_type;
s long;
c number := 0;
begin
f := utl_file.fopen('ABC_EXTRACTS','sample1.txt','R');
loop
utl_file.get_line(f,s);
insert into s values (s);
c := c + 1;
end loop;
exception
when NO_DATA_FOUND then
utl_file.fclose(f);
dbms_output.put_line('No. of rows inserted : ' || c);
end;

prazy the one which you have specified above seems to work fine .but if a word is seperated by the space it is considering as tab (space delimited is considered as tab limited by your query)delimited .
with T as (
select 'john sam alfred nobel samuel thomas' col1 from dual)
select regexp_substr(col1,'[^      ]+',1,4) from t
here alfred nobel is a single name and is seperated by a space .the above query returns nobel but we need samuel .
What i mean to say is space delimited should not be taken into consideration when tab delimited is considered(since if 4 is replaced by 5 in the above query we may get samuel) .
Please advice

Similar Messages

  • How to extract .sit files(in MAC)  using java program

    Hi,
    please help me , i want to simple program for
    " how to extract .sit files(in MAC) using java program"
    that sit files same as zip files in windows..[                                                                                                                                                                                                                                                                                                                                   

    Thanks for reply...
    but i search in the google about this topic...there is no results will appear..
    the problem is "i have to run program in the MacOS like extract all the
    .sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
    please do the needful..i am waiting for ur reply,,,

  • How to set Border in the Excel using UTL_FILE ?

    Hi all,
    Any one aware of
    How to set Border in the Excel using UTL_FILE ?
    Am doing excel creation from a stored procedure.
    Thanks
    Dora

    Hello Dora,
    if you need more than simple csv: at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the package behind the second link supports defining your own formats (and has a tutorial how to do it).
    Regards
    Marcus

  • How to extract local part from email address

    Hello, dear Colleagues.
    Please, help to extract local part from email address.
    Input string: "From: [email protected]"
    Need to get output string between "space" and "@": "C.Norris"
    Thanks.

    Thanks you, mjolinor.
    It works. 
    Could you show me please how to do the same with regular expression?
    Using -replace:
    $InputString = "From: [email protected]"
    $InputString -replace 'From: (.+?)@.+','$1'
    C.Norris
    Using -match:
    $InputString -match 'From: (.+?)@.+' > $null
    $Matches[1]
    C.Norris
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How to extract data from CRICKET MCS410CA using RS232

    I need to extract data from CRICKET and use it for internal Localization of mobile robot.How to use the extracted data to form a map...

    You seem to have the same exact project as someone else... http://forums.ni.com/t5/LabVIEW/cricket-integration/m-p/2052334
    Hmmmmm.....
    Some might think you're all in the same class....

  • How to put the part of text behind someone a shape or a shape?

    I was thinking about something since I've gotten into magazines recently and the design of them. I was wondering how do they put part of the text behind a person on a magazine cover? Or like have have the text look like it's going around a person(like with some parts behind some parts in front of person like a ring of text around a person or a letter "O" encircling someone? I know how to achieve this in photoshop (in a probably non-standard way) but I have no clue how you would achive this in Indesign. I've attached some examples of what I'm talking about.

    How are your Photoshop skills? Because you’ll need to them to silhouette the model. I’d probably just add the magazine title there, too.
    I guess I've always sort of wondered about this...you can do it in Photoshop, sure. But...should you?
    I mean, in Photoshop you split your image into two layers, a foreground layer and a background layer (via whatever mechanisms you like. Magic Wand tool, etc., etc.). And then you add a 3rd layer for the text inbetween those layers.
    But if your cover is normally layed out in InDesign, you've got the text in InDesign already. And what if the text is more complicated than just a plain old title.
    Do you split your Photoshop file into two seperate files (with transparency) and place them on seperate InDesign layers with the text on an ID layer inbetween?
    That seems a bit awkward. Is there a neater solution?
    (I suppose what I would really want would be the ability to have ID insert a layer of ID objects inbetween the two layers of the Photoshop file, and we know that's not possible....)
    I suppose another approach is to keep 2 layers in the Photoshop file and place the image twice, on top of itself, with different layer visibility options in each one. I'm not sure if this is a Clever Idea or a Stupid Trick That Hurts.
    I dunno!

  • How can I change Label's text using ActionScript?

    Hi~ everyone~
    I want change Label's text using ActionScript.
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init()">
    <fx:Script>
      <![CDATA[
       private function init():void{
        var btn:BtnScript = new BtnScript();
        this.addElement(btn);
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label x="182" y="149" text="Label" id="lbl"/>
    </s:Application>
    BtnScript.as
    package
    import flash.events.MouseEvent;
    import mx.controls.Alert;
    import spark.components.Button;
    public class BtnScript extends Button
      public function BtnScript()
       super();
       this.addEventListener(MouseEvent.CLICK, eventHandler);
      private function eventHandler(event:MouseEvent):void{
              // lbl.text = "changed text";
           // HOW CAN I ACCESS LABEL IN MXML FILE?
    I'm about to learn flex. Please help me.
    Thanks in advanced.

    You could achive this very easily(but this shouldn't be used in production code as it'll be difficult to manage as the project grows) by defining a static data member varibale of DataType Label something like below, (modified/added code in BOLD)
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init()"
          creationComplete="creationCompleteHandler(event)">
    <fx:Script>
      <![CDATA[
       private function init():void{
         var btn:BtnScript = new BtnScript();
         this.addElement(btn);
       private function creationCompleteHandler(event:FlexEvent):void{
         Model.someLabel = lbl;
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label x="182" y="149" text="Label" id="lbl"/>
    </s:Application>
    BtnScript.as
    package
      import flash.events.MouseEvent;
      import mx.controls.Alert;
      import spark.components.Button;
      public class BtnScript extends Button
        public function BtnScript()
          super();
          this.addEventListener(MouseEvent.CLICK, eventHandler);
        private function eventHandler(event:MouseEvent):void{
              // lbl.text = "changed text";
          // Now use Model.someLabel which is basically 'lbl'.
          Model.someLabel.text = "changed text";  //Mission Accomplished....
    Model.as
    package
      public class Model
        public static someLabel:Label;
    Note: This approach is just to give you an idea but instead should use the MVC pattern.

  • How to read a specific value or a portion of text using utl_file.

    hi,
    I have a small requirement which goes as follows. I have a text file which is a resultof the sql query and it contains 16 columns as PIPE delimited text . I am using the UTL_FILE package concept to read the data. In general when we use the UTL_FILE.GET_LINE we read the entire line of text. But i need to read the 10th column of the query or the PIPE delimited text .
    Please advice.
    My query goes something like this:
    declare
    f utl_file.file_type;
    s long;
    c number := 0;
    begin
    f := utl_file.fopen('ABC_EXTRACTS','sample1.txt','R');
    loop
    utl_file.get_line(f,s);
    insert into s values (s);
    c := c + 1;
    end loop;
    exception
    when NO_DATA_FOUND then
    utl_file.fclose(f);
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;

    Why don't you use varchar2 instead of long data type. I doubt you can read a portion from a file using utl_file but after doing the fetch you can do substring over the varchar2 variable and retrieve just the 10th column.
    sample sql:
    If your DB is 10g or higher, you can use the below regular expression to retrieve value based on your need.
    PRAZY@11gR1> select regexp_substr('111|222|333|444|555|666|777|888|999|000|aaa|bbb|','[^|]+',1,10) from dual;
    REG
    000
    Elapsed: 00:00:00.00Btwn, if the text file has fixed number of columns at all time, why don't you use a external table instead?
    Regards,
    Prazy
    Edited by: Prazy on Mar 22, 2010 4:11 PM

  • How do we identify the standard texts used in a sap script?

    Hi,
    Is there any way that i can identify the standard texts used in SAP scripts?
    Not manually going to each window in the script and checking.
    Will there be any table where I can look ?
    Thanks,
    krishna.

    Hi,
    GO to the forminfo of the sapscript in SE71..and then search for INCLUDE
    after displaying the form...utilities->form info..
    hope this works..
    Thanks
    Naren

  • How to do inbound and outbound interfacing using UTL_FILE?

    dear members,
    How can we do interfacing from a legacy system to oracle and vice versa using the UTL_FILE package. I mean how to do an INBOUND and OUTBOUND interfacing using utl_file.
    regards
    sandeep

    Hi Sandeep,
    I do not know if I got your question correct.
    Here is my understanding of it, pls correct me if I am wrong:
    You want to read from and write to the OS from inside the DB? Right?
    There are differnt waysa to do so, depanding on your Oracle version:
    1. you can use the initialization parameter UTL_FILE_DIR to specify a directory on OS where you can read from and write to through the package UTL_FILE.
    2. You can use a directory object in the DB to manage read write access to the OS. This is also usable with the package UTL_FILE as location where to read from and write to.
    => CREATE DIRECTORY my_dir AS '/home/oracle/my_directory';
    GRANT read , write ON DIRECTORY my_dir TO scott;
    SELECT * FROM dba_directories;
    You need CREATE ANY DIRECTORY system privilege for this.
    You can use directory objects also for external tables.
    With these you can read from flat files in teh directory on OS with a select statement as if it were a table inside the DB.
    Does this go into the direction you were thinking of?
    Hope it helps for the first.
    Regards,
    Lutz

  • ALV Classic - How to extract the selection long text of TYPE LVC_T_FCAT?

    DATA: e_dyntab_tb  TYPE lvc_t_fcat,
              e_dyntab_wa TYPE lvc_s_fcat,
              t_line_reftab   TYPE REF   TO data.
    *Populate ALV fiels of TYPE LVC_T_FCAT
    MOVE: c_matnr      TO e_dyntab_wa-fieldname.
    MOVE: c_material   TO e_dyntab_wa-scrtext_l.
    APPEND e_dyntab_wa TO e_dyntab_tb.
    LOOP AT t_hwk_date ASSIGNING <fs_hwk_date>. "t_hwk_date is DYNAMIC
        CONCATENATE c_hwk <fs_hwk_date>-index           INTO  e_dyntab_wa-fieldname.
        CONCATENATE c_hwk <fs_hwk_date>-calender_wk INTO  e_dyntab_wa-scrtext_l.
        APPEND e_dyntab_wa TO e_dyntab_tb.
    ENDLOOP.
    *Create dynamic itab from dynamic ALV output
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = e_dyntab_tb          "Pass alv_fcat here
        IMPORTING
          ep_table        = i_reftab.
    * Create Dynamic Work Area and assign to FS
    ASSIGN i_reftab->* TO <fs_final_itab>.      "Assigning the Final Table,
    CREATE DATA t_line_reftab LIKE LINE OF <fs_final_itab>.
      ASSIGN t_line_reftab->* TO <fs_line_reftab>.  "Create a Work Area
    QUESTION:
    e_dyntab_wa-fieldname   = this is the fieldname / column heading for the dynamic internal table
    e_dyntab_tb-scrtext_l     = this "should" be the 1st row(Column Heading Title) for the dynamic itab
                                        = this data will be used for MS Excel Functionality as always as the first row as
                                           column heading in the MS Excel
    Legend:
    How can I extract the entries of e_dyntab_tb-scrtext_l to an internal table containing the same structure of <fs_line_reftab>?

    Maybe I missed something, but you already have the long text for the columns in your FCAT structure.  The problem you will have is that you will NOT be able to place those fields in the table that you have created because the headings will always be text and the columns may or may not be text (i.e. placing a heading into a numeric).  You will be required to use a different structure.
    Since you are writing a custom export, you will need to do one of the following:
    Option A:
    1.  Retrieve the layout from the ALV as it will not necessarily be the same as when the original was created.  The user may have moved a column or hidden one.
    2.  Create a structure for the export file that has only text fields.  It should contain all of the columns from the FCAT.  This can be done by creating another dynamic table and using the original FCAT and current layout.
    3.  Insert the headings as the first row of the export file.
    4.  Loop thru the internal table, compare it with the layout, and only insert the requested records into the export file.
    5.  Export the file.
    or Option B:
    1.  Make sure the internal table has only text fields and insert the headings as the first record.
    2.  Insert all other records with fields converted to alphanumeric.
    3.  Use the standard export function.
    Hope this helps,
    Brian

  • How can I load and save text using FileReference class

    Let me start by saying I have no intention of using php and I can't wait until flash cs5 comes out with its new read/write capabilities
    I want to load and save XML files (stored on my local hard-drive) in AS3.
    I am using the FileReference class.
    Firstly I have noticed that when using FileReference.save if you replace an existing file instead of writing over the file data is appended to the end of the file. Can I make it so the file is overwritten (as it should be) or make it impossible for the user to save in such a situation.
    Secondly I want to load in text from an external file using FileReference.load I know that somehow you use FileReference.browse first to get it to work but I want to know exactly how to do it.
    I have looked for a tutorial about loading text in this manner and have not found one.
    Any help would be much appreciated especially if you could point me in the direction of a relevant tutorial
    Thanks

    the filereference class is for downloading and uploading files.
    if you want to load xml, use the xml class.
    and, if you want to write to an xml file and don't want to use server-side code, wait.

  • How to extract multiple parts of a .rar file

    How would I extract files like this

    Usually you just click on the first one and the different parts take care of themselves.
    Try UnRarX - Mac OS X RAR Extraction Utility

  • How to extract the number from image using java

    Hello every one
    i want to develope a project which can extract the number from image
    that i can use as inter or String or char.
    Is there any API in java which provide this type of facility.
    right now i m using java 5
    thanks in Advance
    Jignesh

    In my project i have a image in that i have a
    co-ordinate (x,y) I am still puzzled as to what you seek. It sounds to me like you have a point (x, y) represented by p. in java it's just p.getX() p.getY()
    i want to convert that cordinate to numeric form,
    i mena i want to use that cordinate in somewhere else
    in project.point.getX() point.getY()
    So need to convert it into numeric form u can called
    it OCR also.OCR is optical character recognition. If I want out and took a picture of the US Declaration of Independence and then wanted the words on the parchement in the picture in text form, then I would run the picture through a software program and it would try to optically recognise what lettering and number were present in the picture. In the end, I would have a text of what is written on the US Declaration of Independence.
    Is that what you want?

  • How do paint a part of text in the textarea ?

    can i paint (in different color ) just a part of a text in the
    textatra ?
    pease help

    if you're fluent in html, you can use JEditorPane like so:
    JEditorPane j = new JEditorPane("text/html","");Then you can use html in it like this:
    j.setText("<font color=green>green</font>,<font color=red>red</font>");More information:
    http://java.sun.com/j2se/1.4/docs/api/javax/swing/JEditorPane.html

Maybe you are looking for

  • Using itunes on new computer

    can anyone help. i recently had to format my computer (windows xp) and had to delete all the itunes and ipod apps. when i have gone in to re-install itunes and update it everything went ok only all my songs are on my ipod and are'nt in my library. ca

  • SQL QUERY updateable report with APEX_ITEM fields to update hidden columns

    Here is my SQL query: select "EMPLOYEE_ID", "PUBLICATION_ID", "TITLE", '<NOBR>1. ' || APEX_ITEM.TEXT(101,CODE1,2,3) || '  ' || APEX_ITEM.TEXT(102,CODE1_PCT,2,3) || ' %</NOBR><BR>' || '<NOBR>2. ' || APEX_ITEM.TEXT(103,CODE2,2,3) || '  ' || APEX_ITEM.T

  • Hiding lines in a query while using the overall results

    Hi all, We got a hierarchy with 4 levels. Each element of the first level after the root "L1" (2nd level in real) receive amounts called "INITIAL". The next step is to send and dispatch these amounts to the 3rd level "L2". At this point, the L2s can

  • Time machine puts icons back on desktop

    whenever Time Machine backs up my computer, icons for Adobe Flash player, Firefox, hp, etc. appear on my desktop. Is there any way I can stop this from happening?

  • Equinum A100-337: Installing an unsupported OS - Longhorn 4033

    Ok i have a Equinum a100-337 and im trying to install another OS other than Vista. I'm instaling longhorn 4033 and im having driver problems, The exact same thing is happening on windows XP It's not my OS. I've tried the chipset utility which fixes t