... reading text file to load data

Hi all.
we have a requirement, acc to which we need to read a few tab delimited text file into oracle tables on daily bases.
i was trying to read it through the utl_file procedure, but while working i found out that there is a limitation in utl_file ... you can only read a complete line, and i had no clue how to use the delimiter to read each column and insert into database.
Another option i have is to use External table, use these text file as external table and insert data into oracle tables.
There is one problem where i got stuck, probably due to inexperience.
One of the files we recieve is like .
SID, teacher1_Name, teacher1_age, teacher1_sex,teacher2_name,teacher2_age, teacher2_sex......
while the table structure is like
SID Teacher_name, age sex .... ............
Now how can i insert the values for teacher1_age into age column...
so that my db table will be filled like
S1 teacher1_name teacher1_age teacher1_sex
S1 teacher2_name teacher2_age teacher2_sex
Please also suggest that is my method correct for reading these file by making them external tables and then inserting into our db tables.
The reason i cant keep the files is that the data comes daily with changed values, so we need to read them daily and then delete or replace with the new one coming with same name and struture the next day..
Regards

Look at SQL*Loader
See also an External Table Example

Similar Messages

  • Help with windows powershell - reading text file & manipulating the data

    Hello,
    I'm new to windows power shell & need your help/expertise in formatting the below *.txt file.
    Could you please provide me with a sample powershell script which can accomplish the below request. Thank you so much for your help in advance.
    <name>,<ticker>,<date>,<open>,<high>,<low>,<close>,<vol>,<oi>
    GOOG 10-Jan-2014 1165 Put,GOOG140110P01165000,20140114,32.9,32.9,32.9,32.9,0,0
    GOOG 10-Jan-2014 1170 Put,GOOG140110P01170000,20140114,40.87,40.87,40.87,40.87,0,0
    GOOG 10-Jan-2014 1180 Put,GOOG140110P01180000,20140114,54.8,54.8,54.8,54.8,0,0
    GOOG 10-Jan-2014 1190 Put,GOOG140110P01190000,20140114,50.9,50.9,50.9,50.9,0,0
    GOOG 10-Jan-2014 1200 Put,GOOG140110P01200000,20140114,60.9,60.9,60.9,60.9,0,0
    GOOG 10-Jan-2014 1300 Put,GOOG140110P01300000,20140114,157.8,157.8,157.8,157.8,0,0
    PCLN 10-Jan-2014 1170 Call,PCLN140110C01170000,20140114,0.05,0.05,0.05,0.05,0,873
    PCLN 10-Jan-2014 1172.5 Call,PCLN140110C01172500,20140114,0.01,0.01,0.01,0.01,0,136
    PCLN 10-Jan-2014 1175 Call,PCLN140110C01175000,20140114,0.15,0.15,0.15,0.15,0,666
    PCLN 10-Jan-2014 1177.5 Call,PCLN140110C01177500,20140114,0.05,0.05,0.05,0.05,0,174
    PCLN 10-Jan-2014 1180 Call,PCLN140110C01180000,20140114,0.02,0.02,0.02,0.02,0,896
    PCLN 10-Jan-2014 1182.5 Call,PCLN140110C01182500,20140114,0.07,0.07,0.07,0.07,0,138
    PCLN 10-Jan-2014 1185 Call,PCLN140110C01185000,20140114,0.05,0.05,0.05,0.05,0,842
    PCLN 10-Jan-2014 1187.5 Call,PCLN140110C01187500,20140114,0.05,0.05,0.05,0.05,0,36
    PCLN 10-Jan-2014 1190 Call,PCLN140110C01190000,20140114,0.01,0.01,0.01,0.01,0,909
    PCLN 10-Jan-2014 1192.5 Call,PCLN140110C01192500,20140114,0.2,0.2,0.2,0.2,0,88
    PCLN 10-Jan-2014 1195 Call,PCLN140110C01195000,20140114,0.04,0.04,0.04,0.04,0,835
    PCLN 10-Jan-2014 1197.5 Call,PCLN140110C01197500,20140114,0.25,0.25,0.25,0.25,0,22
    PCLN 10-Jan-2014 1200 Call,PCLN140110C01200000,20140114,0.04,0.04,0.04,0.04,0,1073
    PCLN 10-Jan-2014 1205 Call,PCLN140110C01205000,20140114,0.05,0.05,0.05,0.05,0,434
    PCLN 10-Jan-2014 1210 Call,PCLN140110C01210000,20140114,0.03,0.03,0.03,0.03,0,346
    PCLN 10-Jan-2014 1215 Call,PCLN140110C01215000,20140114,0.05,0.05,0.05,0.05,0,288
    Z 22-Feb-2014 80 Call,Z140222C00080000,20140114,11.5,11.5,11.5,11.5,4,335
    Z 22-Feb-2014 85 Call,Z140222C00085000,20140114,7.83,7.83,7.83,7.83,21,523
    Z 22-Feb-2014 90 Call,Z140222C00090000,20140114,5.74,5.74,5.74,5.74,42,422
    Z 22-Feb-2014 95 Call,Z140222C00095000,20140114,3.89,3.89,3.89,3.89,37,389
    Z 22-Feb-2014 100 Call,Z140222C00100000,20140114,2.54,2.54,2.54,2.54,44,576
    Z 22-Feb-2014 105 Call,Z140222C00105000,20140114,1.62,1.62,1.62,1.62,3,117
    Z 22-Feb-2014 110 Call,Z140222C00110000,20140114,0.99,0.99,0.99,0.99,15,215
    The ticker symbol in above file is max of 19 bytes. The software I use cannot convert this data, as it has a restriction of 14 bytes for ticker field.
    I want to reduce the ticker field to 14 bytes using below logic & rewrite the modified symbol in the same column/file.
    GOOG140110P01165000 - Ticker explanation is as shown below
    Symbol : GOOG  ( 4 bytes)
    Year : 14 ( 2 bytes)
    Month : 01 ( 2 bytes)
    Date : 10 ( 2 bytes)
    Call/Put : C or P ( 1 byte) 
    Strike : 01165 ( 5 bytes )
    Strike (Decimal) : 000 ( 3 bytes)
    Since they total to 19 bytes,my requirement is to bring down the ticker field size to 14 bytes using below formula.
    1) Reduce year field to 1 byte i.e. 14 can be kept as 4
    2) Strike ( Decimal) can be reduced to 1 byte ( drop the ending 2 bytes)
    3) Month column ( 2 bytes) & call/put ( 1 byte) can be reduced to 1 byte ( saving of 2 bytes) by replacing 01 & C combination with A , 01 & P combination with B so on as mentioned below.
    Month( 2 bytes)
    Call/Put ( 1 byte)
    Replace with
    01
    C
    A
    01
    P
    B
    02
    C
    C
    02
    P
    D
    03
    C
    E
    03
    P
    F
    04
    C
    G
    04
    P
    H
    05
    C
    I
    05
    P
    J
    06
    C
    K
    06
    P
    L
    07
    C
    M
    07
    P
    N
    08
    C
    O
    08
    P
    P
    09
    C
    Q
    09
    P
    R
    10
    C
    S
    10
    P
    T
    11
    C
    U
    11
    P
    V
    12
    C
    W
    12
    P
    X
    So the modified ticker will look like GOOG4B10011650
    GOOG - symbol
    4 - year which is 2014 in this case 
    B- 01 ( jan) & Put (P) is replaced with letter B
    10 - Date
    01165 - Strike price
    0 - Decimal portion of strike price
    The output file should look like below.
    <name>,<ticker>,<date>,<open>,<high>,<low>,<close>,<vol>,<oi>
    GOOG 10-Jan-2014 1165 Put,GOOG410B011650,20140114,32.9,32.9,32.9,32.9,0,0
    Thank you for your inputs with this request.
    Regards,
    Aimforsky

    Hi Neothwin,
    Thank you for your prompt response. I really appreciate it. My file contains a header record.
    I ran the conversion, it converts very fast.
    I noticed the decimal portion of strike is lost in the conversion. AAL140110C00023500 must be converted as AAL4A1000235 but instead its showing as AAL4A10000230 ( last byte
    should be 5 but it shows as 0)
    Also I noticed it puts double quotes ('') in front of every column. I tried to drop ' in the code but it complains.
    Also, instead of giving file name in the shell script , is it possible to go thru all files in a folder and convert them? I'm new to this scripting/programming sorry if I ask you the basic questions. Thank you so much for sparing your valuable time on this
    request. Have a great day ! 
    ORIGINAL FILE<name>,<ticker>,<date>,<open>,<high>,<low>,<close>,<vol>,<oi>
    AAL 10-Jan-2014 23.5 Call,AAL140110C00023500,20140115,1.85,1.85,1.85,1.85,0,0
    AAL 10-Jan-2014 24 Call,AAL140110C00024000,20140115,5.8,5.8,5.8,5.8,0,0
    AAL 10-Jan-2014 24.5 Call,AAL140110C00024500,20140115,2.05,2.05,2.05,2.05,0,0
    AAL 10-Jan-2014 25 Call,AAL140110C00025000,20140115,2.3,2.3,2.3,2.3,0,0
    AAL 10-Jan-2014 25.5 Call,AAL140110C00025500,20140115,1.35,1.35,1.35,1.35,0,0
    AAL 10-Jan-2014 26 Call,AAL140110C00026000,20140115,3.4,3.4,3.4,3.4,0,0
    AAL 10-Jan-2014 26.5 Call,AAL140110C00026500,20140115,2.65,2.65,2.65,2.65,0,0
    AAL 10-Jan-2014 27 Call,AAL140110C00027000,20140115,2.26,2.26,2.26,2.26,0,0
    AAL 10-Jan-2014 27.5 Call,AAL140110C00027500,20140115,1.75,1.75,1.75,1.75,0,0
    AAL 10-Jan-2014 28 Call,AAL140110C00028000,20140115,1.45,1.45,1.45,1.45,0,0
    AAL 10-Jan-2014 28.5 Call,AAL140110C00028500,20140115,0.9,0.9,0.9,0.9,0,0
    AAL 10-Jan-2014 29 Call,AAL140110C00029000,20140115,0.4,0.4,0.4,0.4,0,0
    AAL 10-Jan-2014 29.5 Call,AAL140110C00029500,20140115,0.05,0.05,0.05,0.05,0,4812
    AAL 10-Jan-2014 30 Call,AAL140110C00030000,20140115,0.05,0.05,0.05,0.05,0,636
    AAL 10-Jan-2014 21.5 Put,AAL140110P00021500,20140115,0.08,0.08,0.08,0.08,0,11
    AAL 10-Jan-2014 23 Put,AAL140110P00023000,20140115,0.05,0.05,0.05,0.05,0,51
    AAL 10-Jan-2014 23.5 Put,AAL140110P00023500,20140115,0.05,0.05,0.05,0.05,0,235
    AAL 10-Jan-2014 24 Put,AAL140110P00024000,20140115,0.1,0.1,0.1,0.1,0,77
    AAL 10-Jan-2014 24.5 Put,AAL140110P00024500,20140115,0.05,0.05,0.05,0.05,0,292
    AAL 10-Jan-2014 25 Put,AAL140110P00025000,20140115,0.05,0.05,0.05,0.05,0,1380
    AAL 10-Jan-2014 25.5 Put,AAL140110P00025500,20140115,0.02,0.02,0.02,0.02,0,1549
    AAL 10-Jan-2014 26 Put,AAL140110P00026000,20140115,0.1,0.1,0.1,0.1,0,665
    AAL 10-Jan-2014 26.5 Put,AAL140110P00026500,20140115,0.02,0.02,0.02,0.02,0,632
    AAL 10-Jan-2014 27 Put,AAL140110P00027000,20140115,0.05,0.05,0.05,0.05,0,2161
    AAL 10-Jan-2014 27.5 Put,AAL140110P00027500,20140115,0.1,0.1,0.1,0.1,0,310
    AAL 10-Jan-2014 28 Put,AAL140110P00028000,20140115,0.01,0.01,0.01,0.01,0,642
    AAL 10-Jan-2014 28.5 Put,AAL140110P00028500,20140115,0.05,0.05,0.05,0.05,0,291
    AAL 10-Jan-2014 29 Put,AAL140110P00029000,20140115,0.05,0.05,0.05,0.05,0,6728
    AAL 10-Jan-2014 29.5 Put,AAL140110P00029500,20140115,0.3,0.3,0.3,0.3,0,0
    AAL 10-Jan-2014 30 Put,AAL140110P00030000,20140115,4.3,4.3,4.3,4.3,0,0
    AAL 10-Jan-2014 32 Put,AAL140110P00032000,20140115,2.6,2.6,2.6,2.6,0,0
    AAL 18-Jan-2014 0.5 Call,AAL140118C00000500,20140115,11,11,11,11,0,180
    AAL 18-Jan-2014 1 Call,AAL140118C00001000,20140115,27.9,27.9,27.9,27.9,0,68
    AAL 18-Jan-2014 2 Call,AAL140118C00002000,20140115,22.7,22.7,22.7,22.7,0,7
    AAL 18-Jan-2014 3 Call,AAL140118C00003000,20140115,17.15,17.15,17.15,17.15,0,10
    CONVERTED FILE:"<name>","<ticker>","<date>","<open>","<high>","<low>","<close>","<vol>","<oi>"
    "AAL 10-Jan-2014 23.5 Call","AAL4A10000230","20140115","1.85","1.85","1.85","1.85","0","0"
    "AAL 10-Jan-2014 24 Call","AAL4A10000240","20140115","5.8","5.8","5.8","5.8","0","0"
    "AAL 10-Jan-2014 24.5 Call","AAL4A10000240","20140115","2.05","2.05","2.05","2.05","0","0"
    "AAL 10-Jan-2014 25 Call","AAL4A10000250","20140115","2.3","2.3","2.3","2.3","0","0"
    "AAL 10-Jan-2014 25.5 Call","AAL4A10000250","20140115","1.35","1.35","1.35","1.35","0","0"
    "AAL 10-Jan-2014 26 Call","AAL4A10000260","20140115","3.4","3.4","3.4","3.4","0","0"
    "AAL 10-Jan-2014 26.5 Call","AAL4A10000260","20140115","2.65","2.65","2.65","2.65","0","0"
    "AAL 10-Jan-2014 27 Call","AAL4A10000270","20140115","2.26","2.26","2.26","2.26","0","0"
    "AAL 10-Jan-2014 27.5 Call","AAL4A10000270","20140115","1.75","1.75","1.75","1.75","0","0"
    "AAL 10-Jan-2014 28 Call","AAL4A10000280","20140115","1.45","1.45","1.45","1.45","0","0"
    "AAL 10-Jan-2014 28.5 Call","AAL4A10000280","20140115","0.9","0.9","0.9","0.9","0","0"
    "AAL 10-Jan-2014 29 Call","AAL4A10000290","20140115","0.4","0.4","0.4","0.4","0","0"
    "AAL 10-Jan-2014 29.5 Call","AAL4A10000290","20140115","0.05","0.05","0.05","0.05","0","4812"
    "AAL 10-Jan-2014 30 Call","AAL4A10000300","20140115","0.05","0.05","0.05","0.05","0","636"
    "AAL 10-Jan-2014 21.5 Put","AAL4B10000210","20140115","0.08","0.08","0.08","0.08","0","11"
    "AAL 10-Jan-2014 23 Put","AAL4B10000230","20140115","0.05","0.05","0.05","0.05","0","51"
    "AAL 10-Jan-2014 23.5 Put","AAL4B10000230","20140115","0.05","0.05","0.05","0.05","0","235"
    "AAL 10-Jan-2014 24 Put","AAL4B10000240","20140115","0.1","0.1","0.1","0.1","0","77"
    "AAL 10-Jan-2014 24.5 Put","AAL4B10000240","20140115","0.05","0.05","0.05","0.05","0","292"
    "AAL 10-Jan-2014 25 Put","AAL4B10000250","20140115","0.05","0.05","0.05","0.05","0","1380"
    "AAL 10-Jan-2014 25.5 Put","AAL4B10000250","20140115","0.02","0.02","0.02","0.02","0","1549"
    "AAL 10-Jan-2014 26 Put","AAL4B10000260","20140115","0.1","0.1","0.1","0.1","0","665"
    "AAL 10-Jan-2014 26.5 Put","AAL4B10000260","20140115","0.02","0.02","0.02","0.02","0","632"
    "AAL 10-Jan-2014 27 Put","AAL4B10000270","20140115","0.05","0.05","0.05","0.05","0",”2161"

  • Read text file insert into table using utl_file

    Hi
    i have script for read and insert into table but i want error records load into error table so i sent you my script and please fix the error log table
    script
    DECLARE
    v_line VARCHAR2(2000);
    v_file utl_file.file_type;
    v_dir VARCHAR2(250);
    v_filename VARCHAR2(50);
    BEGIN
    v_dir :='MID5010_DOC1TP';
    v_filename := 'OPT_CM_BASE.txt';
    v_file := utl_file.fopen(v_dir, v_filename, 'r');
    LOOP
    BEGIN
    utl_file.get_line(v_file, v_line);
    EXCEPTION
    WHEN no_data_found THEN
    EXIT;
    END ;
    v_line := REPLACE(v_line,'|','|~');
    INSERT
    INTO optum_icd10cm_base VALUES
    ( REPLACE(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,1),'a~','a'),'.'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,2),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,3),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,4),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,5),'a~','a'),
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,6)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,6),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,6),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,7)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,7),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,7),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,8)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,8),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,8),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,9)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,9),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,9),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,10)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,10),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,10),'a~','a'),'mm-dd-yyyy')
    END,
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,11),'a~','a')
    -----commit;
    END LOOP;
    utl_file.fclose(v_file);
    END;
    text file
    A50.0||Short|Long|Full|01-01-2009|01-2009||01-01-2013|09-18-2012|C|
    A50.1||Short|Long|Full|01-01-2009|01-01-2009||001-2013|09-18-2012|C|
    A50.2||Short|Long|Full|01-01-2009|01-01-2009|67|01-01-2013|09-18-2012|C|
    A50.3||Short|Long|Full|011-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.4||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|5|
    A50.5|R|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.6||Short|Long||01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.7||Short||Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    2345||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    B222|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.2|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.3|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    D642|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.5|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.6|D|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.7|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A001|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A009|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.10|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A0109|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A30|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A316|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A317|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    ----clearly read text file insert into table and error records load into error table
    please help me

    hI
    i am using utl_file prepared script but i got error like 01861. 00000 - "literal does not match format string"
    script:
    DECLARE
    f utl_file.file_type;
    s VARCHAR2(32000);
    f1 VARCHAR2(100);
    f2 varchar2(100);
    F3 VARCHAR2(100);
    F4 VARCHAR2(100);
    F5 VARCHAR2(100);
    F6 DATE;
    F7 DATE;
    F8 DATE;
    F9 DATE;
    F10 DATE;
    f11 CHAR(1);
    BEGIN
    --DBMS_OUTPUT.ENABLE(100000);
    f := utl_file.fopen('MID5010_DOC1TP', 'OPT_CM_BASE.txt', 'R');
    LOOP
    BEGIN
    UTL_FILE.GET_LINE(f, s);
    f1 := REGEXP_SUBSTR (s,'[^|]+',1,1);
    f2 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,2);
    F3 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,3);
    F4 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,4);
    F5 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,5);
    F6 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,6),'mm-dd-yyyy');
    F8 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,8),'mm-dd-yyyy');
    F7 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,7),'mm-dd-yyyy');
    F9 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,9),'mm-dd-yyyy');
    F10 :=to_date(REGEXP_SUBSTR (REPLACE(s,'||','||') ,'[^|]+',1,10),'mm-dd-yyyy');
    f11 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,11);
    INSERT
    INTO OPTUM_ICD10CM_BASE
    ( CODE,
    STATUS,
    SHORT_DESCRIPTION,
    LONG_DESCRIPTION,
    FULL_DESCRIPTION,
    CODE_EFFECTIVE_DATE,
    CHANGE_EFFECTIVE_DATE,
    TERMINATION_DATE,
    RELEASE_DATE,
    CREATION_DATE,
    VALIDITY
    VALUES
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    f11
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    UTL_FILE.FCLOSE(F);
    END;
    please help me(in my org looks utl_file standards only)

  • Read Text file and count occurences of certain string

    Hello,
    I have a text file with lines of data in it. I would like to read this text file and count how many lines match a certain string of text. 
    For example my text file has this data in it.
    dog,blue,big
    dog,red,small
    dog,blue,big
    cat,blue,big
    If the certain string of text is "dog,blue,big" then the count would return "2".
    Thanks for your help

    Hello,
    Thank you for your post.
    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    In addition, if you are working with Windows Forms app. please consult on Windows Forms Forum:http://social.msdn.microsoft.com/Forums/windows/en-US/home?category=windowsforms
    If you are working with WPF app, please consult on WPF forum:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf
    If you are working with ASP.NET Web Application, I suggest that you can consult your issue on ASP.NET forum:
    http://forums.asp.net/
     for better solution and support.
    Visual Studio Language Forums:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Read text file and insert into MySQL

    Dears,
    I need to read text file and then insert the data in the correct column in the MySQL database
    example
    I have the following text file:
    field1=1234 field2=56789 field3=444555
    field1=1333 field2=2222 field3=333555
    and so on and so forth ,,note that all rows are identical and just the filed value is changed(there is a dilemeter between fields)
    how can I read field1,field2 and field3 from text file and insert them in the correct table and column in the database.....
    any help?????
    thanks for your cooperation
    Best Regars

    Sure.
    Which part don't you understand?
    1. Reading a text file
    2. Parsing the text file contents.
    3. Relational databases and SQL.
    4. How to create a database.
    5. How to connect to a database in Java.
    6. How to insert records into the database in Java.
    7. How to map Java objects to records in a database.
    This is a pretty nice list. Solve complex problems by breaking them into smaller ones.
    %

  • How to create and read text file using LabVIEW 7.1 PDA module?

    How to create and read text file using LabVIEW 7.1 PDA module? I can not create a text file and read it.
    I attach my code here.
    Attachments:
    File_IO.vi ‏82 KB

    Well my acquisition code runs perfect. The problem is reading it. I can't seem to read my data no matter what I do. My data gets saved as a string using the array to string vi but I've read that the string to array vi (which I need to convert back to array to read my data) does not work on the pda. I'm using version 8.0. So I was trying to modify the program posted in this discussion so that it would save data from my DAQ. I did that but I still can't read the data after its saved. I really don't know what else to do. All I need to do is read the data on the pda itself. I can't understand why I'm having such a hard time doing that. I found a possible solution on another discussion that talks about parsing the strings because of the bug in the "string to array" vi. However, that lead me to another problem because for some reason, the array indicators or graphs don't function on the pda. When i build the program to the pda or emulator, the array indicators are faded out on the front panel as if the function is not valid. Does this kind of help give a better picture of what I'm trying to do. Simply read data back. Thanks.

  • How can FMS create a text file and write data into it in the Server application folders?

    Recently, I writed a programe about creating a text file and writing data into it in the server application folder. My code is as following:
               var fileObj = new File("/MyApp/test.txt");
               if( fileObj !=  null)
                      if(fileObj.open( "text", "append"))
                            fileObj.write( "                                                      ———— Chat Info Backup ————\r\n" );
                            fileObj.close( );
                            trace("Chat info backup document :" +  fileObj.name + " has been created successfully!");    
    But when I run it, FMS throw the error as following: File operation open failed  ;  TypeError: fileObj has no properties.
    Can you help me ? Thanks in advance.
    Supplement: The text file named test.txt doesn't exist before create the fileObj, an instance of File Class.

    Is MyApp the name of the application directory, or is it a child of the application directory? If myApp is the app name, just use test.txt as the path flag in the file constructor.

  • To read text file using utl_file

    I would like to read test_file_out.txt which is in c:\temp folder.
    create or replace create or replace directory dir_temp as 'c:\temp';
    grant read, write on directory dir_temp to system;
    then when i execute the below code i get the error .
    // to read text file using utl_file
    DECLARE
    FileIn UTL_FILE.FILE_TYPE;
    v_sql VARCHAR2 (1000);
    BEGIN
    FileIn := UTL_FILE.FOPEN ('DIR_TEMP', 'test_file_out.txt', 'R');
    UTL_FILE.PUT_LINE (FileIn, v_sql);
    dbms_output.put_line(v_sql);
    UTL_FILE.FCLOSE (FileIn);
    END;
    ERROR:
    invalid file operation
    i would like to use ult_file only and also can you let me know to read the text file and place its contents in tmp_emp table?

    Are you trying to read the contents of the file into the local variable? Or write the contents of the local variable to the file?
    Your text talks about reading the file. And you open the file in read mode. But then you call the UTL_FILE.PUT_LINE method which, as SomeoneElse points out, attempts to write data to the file. Since the file is open in read-only mode, you cannot write to the file.
    If the goal is really to read from the file, replace the UTL_FILE.PUT_LINE calls with UTL_FILE.GET_LINE. If the goal is really to write to the file, you'll need to open the file in write mode ('W' rather than 'R' in the FOPEN call).
    Justin

  • How to read text file efficiently?

    I use CharBuffer to read text file:
    private List<String> load() throws IOException {
            final String B = "<BODY>";
            final String E = "</BODY>";
            List<String> docs = new ArrayList<String>();
            for (File file : files) {
                FileReader reader = new FileReader(file);
                CharBuffer buffer = CharBuffer.allocate(BSIZE);
                StringBuilder sb = new StringBuilder();
                while (reader.read(buffer) != -1) {
                    char[] dst = new char[buffer.length()];
                    buffer.get(dst);
                    sb.append(dst);
                    buffer.clear();
                String s = sb.toString();
                System.out.println(file + ": " + s.length());
                int start = 0;
                int i, j;
                while ((i = s.indexOf(B, start)) != -1) {
                    j = s.indexOf(E, i + B.length());
                    docs.add(s.substring(i + B.length(), j));
                    start = j + E.length();
                    //System.out.printf("%d %d %d%n", i, j, start);
            return docs;
        }The file size is 1324350, but the code say it is 772802.
    What's wrong with this code?
    I want to read text file as quickly as possible.
    Is this code the right way to read file?
    Should I use FileReader or nio Channel and ByteBuffer?
    Any suggestions are welcome!

    You are reading the file as if it were encoded in UTF-16. Each character uses two bytes so you have half the number of characters as you had bytes.
    The following code reads an entire file in one hit.
        public static String readText(File file) throws IOException {
            byte[] bytes = new byte[(int) file.length()];
            DataInputStream dis = new DataInputStream(new FileInputStream(file));
            try {
                dis.readFully(bytes);
            } finally {
                dis.close();
            return new String(bytes, "UTF-8"); // or whatever your file encoding is.
        }But you can still have less characters than bytes if there are any non ASCII-7 characters.

  • How to read text file?

    Dear Everyone
    I have coding below.
    {color:#3366ff}*Text file scores.txt*
    {color}1 1 1
    2 2 2
    *{color:#3366ff}Java class jtableone.class{color}*
    import javax.swing.*;
    public class jtableone extends JApplet {
    public static void main(String[] args) throws Exception {
    {color:#ff0000}//Read file scores.txt{color}
    java.io.File file = new java.io.File("scores.txt");
    Scanner input = new Scanner(file);
    while (input.hasNext()){
    String id = input.next();
    String firstname = input.next();
    String lastname = input.next();
    {color:#ff0000}//System.out.println(id +" "+ firstname +" "+ lastname);
    {color}}
    input.close();
    {color:#ff0000}//Crearte JTable{color}
    private String[] columNames =
    {"ID", "First Name", "Last Name"};
    private Object[][] data = {
    //{"12", "Tom", "Clark"},
    //{"13", "helen", "Tan"}
    {color:#ff0000}//Display JTable{color}
    private JTable jTable1 = new JTable(data, columNames);
    public jtableone(){
    add(new JScrollPane(jTable1));
    Can you tell me What i do next?
    Create a Object[][] data which can read text file.
    Thanks
    sevenlon

    sevenlon wrote:
    Can you tell me What i do next?How are we supposed to know? We have no knowledge of what your assignment is.
    Create a Object[][] data which can read text file.Then do that. Create the 2D array and store the data in it.
    Also when posting code use code tags. Paste code, highlight it and click CODE button.

  • Read text file in Flash

    How to read text file flash memory

    Use the 'more' command. Here is a console log showing it in use -
    VG202#dir flash:
    Directory of flash:/
    1 -rw- 18955952 Mar 1 2002 00:19:50 +00:00 vg20x-ipvoice-mz.124-22.T.
    bin
    128843776 bytes total (109887488 bytes free)
    VG202#copy run flash:Myconfig.txt
    Destination filename [Myconfig.txt]?
    1593 bytes copied in 0.392 secs (4064 bytes/sec)
    VG202#dir flash:
    Directory of flash:/
    2 -rw- 1593 Mar 6 2002 19:28:26 +00:00 Myconfig.txt
    1 -rw- 18955952 Mar 1 2002 00:19:50 +00:00 vg20x-ipvoice-mz.124-22.T.
    bin
    128843776 bytes total (109883392 bytes free)
    VG202#
    VG202#more flash:Myconfig.txt
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname VG202
    boot-start-marker
    boot-end-marker
    logging message-counter syslog
    enable password cisco
    no aaa new-model
    ip source-route
    ip cef
    no ipv6 cef
    stcapp ccm-group 1
    stcapp
    stcapp feature access-code
    stcapp feature speed-dial
    stcapp call-control mode feature
    voice-card 0
    archive
    log config
    hidekeys
    interface FastEthernet0/0
    ip address 10.66.75.41 255.255.255.0
    duplex auto
    speed auto
    interface FastEthernet0/1
    no ip address
    shutdown
    duplex auto
    speed auto
    ip forward-protocol nd
    ip route 0.0.0.0 0.0.0.0 10.66.75.1
    no ip http server
    control-plane
    voice-port 0/0
    timeouts initial 60
    timeouts interdigit 60
    timeouts ringing infinity
    voice-port 0/1
    ccm-manager fax protocol cisco
    ccm-manager config server 10.66.90.130
    ccm-manager config
    ccm-manager sccp local FastEthernet0/0
    ccm-manager sccp
    mgcp fax t38 ecm
    sccp local FastEthernet0/0
    sccp ccm 10.66.75.212 identifier 2 version 6.0
    sccp ccm 10.66.75.211 identifier 1 version 6.0
    sccp
    sccp ccm group 1
    associate ccm 1 priority 1
    associate ccm 2 priority 2
    dial-peer voice 1 pots
    service stcapp
    port 0/0
    dial-peer voice 10 pots
    shutdown
    destination-pattern 10
    port 0/1
    dial-peer voice 11 pots
    shutdown
    destination-pattern 11
    port 0/0
    line con 0
    no modem enable
    line aux 0
    line vty 0 4
    password cisco
    login
    exception data-corruption buffer truncate
    end
    VG202#

  • Reading text file to JEditorPane

    Hi,
    I'm trying to read text file to JEditorPane and it works but first line is always missing. Here is the code for reading:
    try {
       in = new BufferedReader(new FileReader(filePathIn));
       while ((lineIn = in.readLine()) != null) {
            editorPane.read(in, new Object());
    } catch (IOException ie)...Any suggestions?

    in.readLine is changing the input stream position.
    Do this instead:
    FileInputStream in = new FileInputStream(filePathIn);
    while (in.available() != 0)
        editorPane.read(in, new Object());

  • In 10g read text files

    i am not able to read text file in 10g forms. using webutil.pll and webutil.lib
    here i posted the code . i am not getting message 2, client_text_io.fopen is not working what could be the reason.
    DECLARE
    in_file client_TEXT_IO.FILE_TYPE;
    V_LINE_COUNT number;
    linebuf VARCHAR2(1800);
    V_var1 varchar2(80);
    V_var2 varchar2(80);
    V_var3 varchar2(80);
    V_var4 varchar2(80);
    V_var5 varchar2(80);
    filename VARCHAR2(30);
    l_var number;
    blnRet BOOLEAN;
    begin
         DELETE FROM NIRU_TEMP;
    :file_path:=LTRIM(RTRIM(:file_path));
    MESSAGE('1');
    in_file := client_text_io.fopen(UPPER(:file_path),'r');
    MESSAGE('2');
    loop
    V_LINE_COUNT := V_LINE_COUNT + 1;
    client_text_io.get_line(in_file,linebuf);
    MESSAGE('5');
    V_var1 := substr(linebuf,1,(instr(linebuf,',')-1)) ;
    MESSAGE('6'||V_VAR1);
    MESSAGE('6'||V_VAR1);
    l_var := length(v_var1);
    V_var2 := substr(linebuf,l_var+2,(instr(linebuf,','))) ;
    --V_var3 := substr(linebuf,15 ,10 );
    V_var2 :=LTRIM(RTRIM(V_var2));
    MESSAGE('6'||V_var2);
    MESSAGE('6'||V_var2);
    :p_id := v_var1;
    :p_desc :=v_var2;
    --IF V_var2 = '' THEN
    --V_var3 :='';
    --else
    --V_var3 := TO_NUMBER(V_var2) ;
    --end if;
    --V_var5 := substr(linebuf,26 ,70 );
    INSERT INTO NIRU_TEMP VALUES (V_var1,V_var2);
    client_text_io.new_line;
    :System.Message_Level := '20';
    commit;
    :System.Message_Level := '0';
    --<<end_loop>>
    --null;
    next_record;
    end loop;
    client_TEXT_IO.FCLOSE(in_file);
    exception
         WHEN OTHERS THEN
         MESSAGE('ERROR'||SQLCODE||' '||SQLERRM);
    --exit;
    end;

    Hello Francois,
    You have a solution for this problem?
    I have a problem like this. While reading a text file, such as size of 7MB, long, between 15-30 minutes.
    See...
    declare
         arq client_text_io.file_type;
         linha varchar2(800);
         v_total number := 0;
         v_icms number := 0;
    begin
    :valor_total := 0;
    :valor_icms := 0;
         arq := client_text_io.fopen(:arquivo,'r');
         loop
         client_text_io.get_line(arq,linha);
         if substr(linha,1,1) = '1' then
              v_total := v_total + (to_number(substr(linha,302,13))/100);
              v_icms := v_icms + (to_number(substr(linha,262,13))/100);
         end if;     
         end loop;
         client_text_io.fclose(arq);
         exception
              when no_data_found then
              :valor_total := v_total;
              :valor_icms := v_icms;
              message('Realizado com sucesso!');
              message('Realizado com sucesso!');
    end;

  • How to read text file content in portal application?

    Hi,
    How do we read text file content in portal application?
    Can anyone forward the code to do do?
    Regards,
    Anagha

    Check the code below. This help you to know how to read the text file content line by line. You can display as you require.
    IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
    IResourceContext resourceContext = new ResourceContext(user);
    String filePath = "/documents/....";
    RID rid = RID.getRID(filePath);
    IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
    InputStream inputStream = resource.getContent().getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line = reader.readLine();
    while(line!=null) {
          line = reader.readLine();
         //You can append in string buffer to get file content as string object//
    Regards,
    Yoga

  • How can I read text files from LAN if I only know the hostname?

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    <p>1. How can I read text files from LAN if I only know the hostname, or IP address?
    <p>2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.
    (ex. how can I read the 120th line?)
    <p>Please help!
    <p>sorry for the bad english

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    1. How can I read text files from LAN if I only know the hostname, or IP address?You need to know the URL of the file. You need to know the hostname, port, protocl and relative path.
    The hostname is server, not file.
    2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.Use the seek() to get to a random byte.
    (ex. how can I read the 120th line?)The only way to find the 120th line is to read the first 120 lines. You can use other file formats to find the 120th line without reading the whole file but to need to be able to detremine where the 120th line is

Maybe you are looking for