Compare two .dat files

Hi all,
Everyday i am producing a full flat file(using utl_file package).i want to compare today's file and yesterdays file. if there is any difference that difference file i want to sent to the onsite.
suppose todays file is abcde and yesterday file is abcd. i want to compare both that difference file is to be sent.
This can be done in only for oracle not in unix.
if anybody having a sample code for this please send it asap
thanks in advance....................
regards,
kiran

here i am giving what i have written
CREATE OR REPLACE PACKAGE batch_kkk11 AS
PROCEDURE batch_extract_kkk11(p_directory IN VARCHAR2 , p_filename IN VARCHAR2) ;
END batch_kkk11;
CREATE OR REPLACE PACKAGE BODY batch_kkk11 AS
PROCEDURE batch_extract_kkk11 (p_directory IN VARCHAR2 , p_filename IN VARCHAR2) AS
v_out_file utl_file.file_type;
v_record_count NUMBER:=2;
v_cnt NUMBER:=1;
v_rec varchar2(5000);
v_rec_type varchar2(10);
v_sep VARCHAR2(2):=CHR(199);
final_t Uii_File_Pack_kkk1.tbl_body;
ename1 kemp.ename%type;
last_update1 kemp.last_update%type;
dname1 kdept.dname%type;
last_update2 kdept.last_update%type;
city1 kcity.city%type;
last_update3 kcity.last_update%type;
CURSOR C_MAIN_CURSOR IS
select ename,kemp.last_update,dname,kdept.last_update,city,kcity.last_update from kcity,
kdept,kemp where kemp.empno=kdept.empno and kdept.deptno=kcity.deptno
and to_char(sysdate,'dd')-to_char(kemp.last_update,'dd')=1
and to_char(sysdate,'dd')-to_char(kdept.last_update,'dd')=1
and to_char(sysdate,'dd')-to_char(kcity.last_update,'dd')=1;
begin
--v_out_file:= utl_file.fopen('c:\temp','zafar'||'.dat','w');
Uii_File_Pack_kkk1.p_write_header_kkk1(p_directory,p_filename,v_out_file);
OPEN C_MAIN_CURSOR ;
LOOP
FETCH C_MAIN_CURSOR INTO
ename1,
last_update1,
dname1,
last_update2,
city1,
last_update3
EXIT WHEN C_MAIN_CURSOR%NOTFOUND;
final_t(1).v_rec:='';
final_t(1).v_rec:=final_t(1).v_rec||v_sep|| ename1;
Final_t(1).v_rec:=final_t(1).v_rec||v_sep|| last_update1;
Final_t(1).v_rec:=final_t(1).v_rec||v_sep|| dname1;
Final_t(1).v_rec:=final_t(1).v_rec||v_sep|| last_update2;
Final_t(1).v_rec:=final_t(1).v_rec||v_sep|| city1;
Final_t(1).v_rec:=final_t(1).v_rec||v_sep|| last_update3;
Uii_File_Pack_kkk1.p_write_rec_kkk1(final_t, v_out_file, v_record_count);
final_t.DELETE();
END LOOP;
--utl_file.fclose(v_out_file);
Uii_File_Pack_kkk1.p_write_footer_kkk1(v_out_file,v_record_count);
END batch_extract_kkk11;
END batch_kkk11;
CREATE OR REPLACE PACKAGE Uii_File_Pack_kkk1
IS
TYPE rec_body IS RECORD(
v_rec varchar2(5000)
TYPE tbl_body IS TABLE OF rec_body INDEX BY BINARY_INTEGER;
PROCEDURE p_write_header_kkk1
(p_dir_name IN VARCHAR2,
p_file_name IN VARCHAR2,
p_out_file IN OUT utl_file.file_type
PROCEDURE p_write_rec_kkk1 (p_rec IN tbl_body,
p_out_file IN utl_file.file_type,
p_record_count IN out NUMBER
PROCEDURE p_write_footer_kkk1 (p_out_file IN out utl_file.file_type,
p_record_count IN NUMBER
END;
CREATE OR REPLACE PACKAGE BODY Uii_File_Pack_kkk1 IS
PROCEDURE p_write_header_kkk1
(p_dir_name IN VARCHAR2,
p_file_name IN VARCHAR2,
p_out_file IN OUT utl_file.file_type
IS
separator VARCHAR2(2) :=chr(199);
v_header_record varchar2(2000);
p_rec_type1 VARCHAR2(20):='01';
BEGIN
p_out_file:=utl_file.fopen(p_dir_name,p_file_name,'w');
v_header_record :=p_rec_type1||separator||TO_CHAR(systimestamp,'YYYYMMDDHH24MISS')||separator;
utl_file.putf(p_out_file,v_header_record);
END p_write_header_kkk1;
PROCEDURE p_write_rec_kkk1 (p_rec IN tbl_body,
p_out_file IN utl_file.file_type,
p_record_count IN out NUMBER )
IS
v_record VARCHAR2(2000);
separator VARCHAR2(2) :=chr(199);
p_rec_type2 number(10):=10;
BEGIN
IF p_rec.COUNT() >0 THEN
FOR i IN p_rec.FIRST..p_rec.LAST
LOOP
v_record := p_rec_type2||p_rec(i).v_rec;
utl_file.putf(p_out_file,v_record);
END LOOP;
END IF;
p_record_count := p_record_count +p_rec.COUNT() ;
END p_write_rec_kkk1;
PROCEDURE p_write_footer_kkk1 (p_out_file IN out utl_file.file_type,
p_record_count IN NUMBER
) IS
v_footer_record VARCHAR2(2000);
p_rec_type number(10):=99;
separator VARCHAR2(2) :=chr(199);
BEGIN
v_footer_record := p_rec_type||separator||LPAD(p_record_count,10,'0');
utl_file.putf(p_out_file, v_footer_record);
utl_file.fclose (p_out_file);
END p_write_footer_kkk1;
END Uii_File_Pack_kkk1;
/

Similar Messages

  • Comparing two text files in a UNIX using shell programming

    Hi All,
    Sorry for posting a UNIX shell query on Database forums.
    I want to compare two text files using shell programming. The two text files are actually Business Objects output extracted in a text format. The two output files are not in a tabular format and are no way similar in looking. I want to take one file e.g. file1 as an input file and compare each line of file1 with the other file e.g. file2. During comparison I want to extract the differences found in another file and if possible the similar data as well.
    Below is how the files will look like
    File 1:
    BILL1000000 1111251 122222
    RMG1A2 023425100000000010001 11135 102650111100
    UHL1 *6999999* *454540001* Weekly *000*
    0544424556895PS DATA 01MPS100000/03 MR A A PERTH UTL1234567893106923455053106900000010000005
    File 2:
    AUTO
    APPLICATION=STARTPOINT
    START
    PROCESSING DATE=01012011
    1598301270320099TEST C E 00000031615 123456
    7854301276140499TES P 00000062943 234567
    UHL1 *6999999* *454540001* Weekly *000*
    5569931233333499/123456789 00000013396 345678
    4471931233333499ER K J 00000031835123456789012456789
    33652931233333499E J L 00000034729123456789012567890
    45783123333349921/123456789 00000039080 678901
    1452931233333499T R 00000040678123456789012789012
    59689312333334994/987654321 00000048614 890123
    4112931233333499/987654321 00000060631 901234
    1236931217836899 K S 00000043704 012345
    END
    As you can see above the file are not at all matching except for one record UHL1, but its just an example. As an output I would like to have a third file containing all these records, highlighting the differences, and a fourth file where in only the matched records should get populated.
    Please post any useful scripts related to the above scenario.
    Many Thanks.
    Edited by: 848265 on 06-Apr-2011 04:13

    Hi;
    For your issue i suggest close your thread here as changing thread status to answere and move it to Forum Home » Linux which you can get more quick response
    Regard
    Helios

  • Comparing two dates+times [bash]

    To compare two dates+times* in bash I have always used date +%s and compared the resulting strings.  Is there a better way to do it?  Thanks.
    * As in "is date+time Y after date+time X?"

    Years ago I wrote a bash script to build a thumbnail gallery webpage for a local directory structure of torrents.  For each torrent, it created the thumbnail of an image with the same name, scraped torrents to get seeders/leechers, parsed a text file of urls and added links below the image with special favicons for commonly linked sites.
    That was a hassle, and I have been afraid to look at the script since I stopped using it.  But the page it produced was pretty sweet.
    Most of the scripts I write are a bit more down-to-earth than that though.
    Last edited by alphaniner (2012-04-25 18:50:02)

  • How can i compare two excel files with different no. of records.

    Hi
    I am on to a small project that involves us to compare two excel files. i am able to do it but am struck up at a point. When i compare 2 different .csv files with different no. of lines i am only able to compare upto a point till when the number of lines is same in both the files.
    Eg. if source file has 8 lines and target file has 12 lines. The difference is displayed only till 8 lines and the remaining 4 lines in source lines are not shown.
    Can you help me in displaying those extra 4 lines in source file. I am attaching my code snippet below..
    while (((strLine = br.readLine()) != null) && ((strLine1 = br1.readLine())) != null)
                     String delims = "[;,\t,,,|]";
                    String[] tokens = strLine.split(delims);
                    String[] tokens1 = strLine1.split(delims);
                   if (tokens.length > tokens1.length)
                    for (int i = 0; i < tokens.length; i++) {
                        try {
                            if (!tokens.equals(tokens1[i])) {
    System.out.println(tokens[i] + "<----->" + tokens1[i]);
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + tokens1[i]);
    out.println();
    sno++;
    } catch (Exception exception)
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + "");
    out.println();
    Thanks & Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    A CSV file is not an Excel file.
    But apart from that your logic makes no sense.
    If the 2 files are of different sizes the files are different by definition, so further comparison isn't needed, you're done.
    If you want to compare individual records, you need to compare all records from one file with all records from the other, unless the order of records is important in which case your current system might work.
    That system however is overly complicated for comparing CSV files.
    As you assume a single record per line, and if one can assume those records to have identical layout (so no leading or trailing whitespace in or between columns in one file that's not in the other) comparing records is simply a matter of comparing the entire lines.

  • Compare two pdf files using adobe acrobat through command line

    Does anyone know how to compare two pdf files using adobe acrobat through command line. I want to do this via command line because we want to compare hundreds of file every day through some automated windows tasks.
    If command line option is not available in acrobat, then is it feasible to make use of acrobat javascript API to do this task?
    Any kind of help will be greatly.

    Command-line: Not possible.
    JavaScript: Possible, but very limited. Basically the only thing you can do is simulate clicking the Compare Documents button. The rest has to be done manually.
    However, it *might* be possible to automate this process a bit more using a plugin. Ask over at the Acrobat SDK forum for more information...

  • How to compare two excel files in java ?

    how do i compare two excel files in java.?
    I have two excel files stored on my computer in d: drive.
    Ex:
    D:\\file a
    D:\\file b
    How to compare the contents of these two files and print " files are equal " or "files not equal "

    Javamastermahe wrote:
    I mean i want to print on the console "files are equal " or any message like " both the files match "If this is your requirement, this program satisfies it...
    import java.util.Random;
    public class SuperExcelTester {
        public static void main(String[] args) {
            Random rnd = new Random();
            String[] messages = {
                "files are equal",
                "files are not equal",
                "unexpected error"
            int index = rnd.nextInt(messages.length);
            System.out.println(messages[index]);
    }

  • Compare two dates in a report

    Hi,
    I would like to compare two dates on a report.
    I would like to compare the opportunity created date and the opportunity modified date. I can't use this formula CASE WHEN Opportunity."Last Modified" = Opportunity."Created Date" then 1 else 0
    I think I have to use TIMESTAMPDIFF but I don't know which interval I have to put to analyze the entire date in this format 31/12/1999 16:49:08
    Thanks a lot for your help
    Regards,

    Hi !
    It depends on the interval you need to compare these dates. If you want to know the number of days between these dates, you'll have to use SQL_TSI_DAY as interval. If it's minutes, you'll need SQL_TSI_MINUTE...
    Here are the possible intervals :
    *SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, or
    SQL_TSI_YEAR*
    Hope this will help, feel free to ask more !
    Max

  • Compare two dates in different format.

    Hi
    I want to compare two dates....one of which is in the timeStamp format ("yyyy-MM-dd HH:mm:ss")
    and the other is in java.util.Date i.e Tue Oct 11 10:22:47 GMT+05:30 2005
    Do I have to tokenise and then compare them.Is there any better approach?
    I want to find out which is greater/smaller one.
    Pls help.
    Regards,
    Sandip.

    I would convert both to Date and compare them. To convert String to Date check java.text.SimpleDateFormat and its parse(...) method.
    HTH
    Mike

  • Compare two text file

    i am comparing two text file by checking occurance of a line in file 1 by comparing it with each line in file 2(not line by line)
    i have to print in 3rd text file as difference
    please see my progrm and tell me modification required
    package comp.vnet.comparator;
    import java.io.*;
    import comp.vnet.comparator.NewFile;
    class FileComparator {
         public static void main(String[] args) throws IOException{
              String file1,file2,String1,String2;
              BufferedReader br1,br2;
              int fileCount1=0;
              int fileCount2=0;
              br1= new BufferedReader(new InputStreamReader (System.in));
              // File file = new File ("output.txt");
              FileWriter fstream = new FileWriter("out.txt");
              // FileOutputStream fo = new FileOutputStream("E:/Filecomparator/FileComparator/output.txt");
              System.out.println("Enter First file name");
              file1="b.txt";
              //file1=br1.readLine();
              System.out.println("Enter Second file name");
              file2="a.txt";
              //file2=br2.readLine();
              NewFile nf= new NewFile();
              br1=nf.creatingFile(file1);
              br2=nf.creatingFile(file2);
    while ((String1= br1.readLine()) != null) {
         fileCount1++;
    while ((String2= br2.readLine()) != null) {
         fileCount2++;
    System.out.println("fileCount1+ : " + fileCount1);
    System.out.println("fileCount2+ : " + fileCount1);
    br1=nf.creatingFile(file1);
    BufferedWriter out = new BufferedWriter(fstream);
    for(int i=0;i<=fileCount1;i++)
         br2=nf.creatingFile(file2);
         String1=br1.readLine();
         for(int j=0;j<fileCount2;j++)
                   String2=br2.readLine();
                        if ( String1.equals (String2) ) {
                             System.out.println("the line is equal");
                        else{
                        out.write(String1);
                             System.out.println(String1);
    out.close();
    br1.close();
    br2.close();
              }

    thanks alot for that reply
    but there is some error
    pleasse send me a nice reply

  • Can I have two Data Files in One control file of sql*loader tool

    hi,
    Can someone help me out. is it possible to have two Data Files in one control file of Sql*loader.
    And isit possible to run 10,000 records before lunch and 10,000 records before tea and 10,000 records before evening session by giving breaks after every 10,000 records.
    Thanks
    Ram

    Yes. You can specify two datafiles in one control file and can load using sql loader.
    I give you the sample control file.
    Load DATA
    INFILE 'TEST1.CSV'
    INFILE 'TEST2.CSV'
    TRUNCATE
    INTO TABLE TEST_P
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (COL_1,
    COL_2,
    COL_n)
    Hope It will help you.
    -Karthik

  • How to compare two XSD files programmatically

    Hi
    I want to compare two XSD files programmatically to find out whether one XSD is a sub set of another XSD(Means checking all the elements and attributes of one schema to be present in another schema).
    Please let me know how this can be done in an efficient way.
    Thanks in advance.
    Mithun K

    Or simply apply an oracle text index on your pdf column:
    SQL>  create table t (id integer primary key, bl blob)
    Table created.
    SQL>  declare
    bf bfile := bfilename('TEMP','b32001.pdf');
    bl blob;
    begin
    dbms_lob.createtemporary(bl,true);
    dbms_lob.open(bf,dbms_lob.lob_readonly);
    DBMS_LOB.LOADFROMFILE(bl, bf,dbms_lob.getlength(bf));
    insert into t values (1,bl);
    commit;
    dbms_lob.close(bf);
    dbms_lob.freetemporary(bl);
    end;
    PL/SQL procedure successfully completed.
    SQL>  create index t_idx on t (bl) indextype is ctxsys.context parameters ('filter ctxsys.auto_filter')
    Index created.
    SQL>  declare
       mklob   clob;
    begin
       ctx_doc.filter ('t_idx', '1', mklob, true);
       dbms_output.put_line (substr (mklob, 1, 250));
       dbms_lob.freetemporary (mklob);
    end;
    Oracle® Database
    Release Notes
    11
    g
    Release 1 (11.1) for Linux
    B32001-04
    November 2007
    This document contains important information that was not included in the
    platform-specific or product-specific documentation
    PL/SQL procedure successfully completed.This generates a text only version of your pdf and standard text comparison methods can be applied ....

  • How to Compare two Dates in java

    How to Compare two Date Field after getting the values from jTextField1.getText() and jTextField2.getText().

    Date d1=DateFormat.getDateInstance().parse(yourstring1);
    same for d2
    d1.compareTo(d2);
    could be that i misrememberd the exact naems of some functions or mixed up something in the equence of d1=

  • Compare two XML files: Analysis and Design

    Hi, Java/XML/JDOM experts,
    I realised that an open source of Java utility to compare two XML is still missing. So I would like to write one for my JDOM excises.
    I plan to do it in three steps:
    1.Define the problem domain.
    2.Design the classes to be developed.
    3.Coding
    Below is the problem domain. Would you review it and tell me if it is fine?
    Best regards,
    AG
    Compare two XML files
    Schema assumption:
    The xml files used for the comparison must have the same schema.
    Definition:
    1. Two elements of simple type are said equal if their name and value are identical.
    2. Two elements of complex type are said comparable if their name, attributes are identical.
    3. Two elements of complex type are said equal if they are comparable and their children elements are identical.

    Hi,
    Thanks for reviewing my idea.
    The xml files used for the comparison must have the
    same schema.Including not having a schema at all? And if they do
    have a schema, must they be valid according to the
    schema?I will only support schema based xml files. To include a schema is a good practice. So I will valid them agaisnt schema (is this possible with JDOM? I am testing ...)
    >
    2. Two elements of complex type are said comparableif
    their name, attributes are identical.
    3. Two elements of complex type are said equal ifthey
    are comparable and their children elements are
    identical.Do you plan to require child elements to appear in the
    same order for the two documents to be equal? (Note
    that XML specifically says that the order of
    attributes is not significant.)No. The order is not significant as I use the attributes as the keys to find comparable element counterpart.
    Here is the sample code already tested. Any comments are welcome!
    The next step is to define the "delta xml schema" that will guide me to store the comparasion results. Do you have any suggestions?
    Regards.
    AG
    public static boolean comparable(Element element1, Element element2)
         boolean returnValue=false;
         if (element1.getName()!=element2.getName()) {
              return returnValue;
    } else {
              returnValue=true;
                        System.out.println ("place 2");
         List attributeList=element1.getAttributes();
         Iterator attributeIterator=attributeList.iterator();
         Attribute workingAttribute=null;
         while (attributeIterator.hasNext()) {
                             if (!workingAttribute.getValue().equals(
                             element2.getAttribute(workingAttribute.getName(), workingAttribute.getNamespace()).getValue()))
                                  returnValue=false;
                                  break;
         return returnValue;

  • How to compare two fmx files

    Hi,
    Is it possible to compare two fmx files , there are few differences between two fmx files , i wanted to know what are the differences.............Thanks.Bcj

    by converting fmb files into xml or text and then using gvimdiff (or similar) on unix or windows will show you the differences. For fmx files, as pointed earlier - you can only see that if they are different or not. On unix you can use strings command (for fmx files) and pipe it to a text file and then do a diff on the files, but that will not be too helpful either.

  • Adobe XI Pro trial verison, when compared two pdf files it gives error  "Expected a Name Object"..Can some one say how to fix this?

    Installed Adobe XI Pro trial verison, when compared two pdf files it gives error  "Expected a Name Object"..Can some one say how to fix this?

    Installed Adobe XI Pro trial verison, when compared two pdf files it gives error  "Expected a Name Object"..Can some one say how to fix this?

Maybe you are looking for

  • Recovery key from MBAM for non TPM machines

    Hi, Since long time am trying to find answer about below query but unlucky , can some one guide me if this is feasiable or not? 1. I have non TPM Machines and want to use Bitlocker with MBAM. 2. if I will use the USB flash driver as start-up key duri

  • How to Fix the OCR?

    Oracle support is taking too long to answer my questions so I hope someone can help. I deleted interfaces from the OCR with oifcfg delif and everything went ok. When I do a oifcfg getif the correct interfaces come back. When I restarted each node in

  • Gamma levels on MacMini/Mountain Lion

    I have migrated my FCP 7 over to a MacMini, upgrading the OS to 10.8 in the process.  The first time, I just used my time machine to copy to the new computer, but all may Final Cut Material showed up with significantly altered gamma levels.  I had to

  • Fireworks CS3 Pages export internal error from Page naming?

    When exporting a set of linked "Pages" to HTML, I was getting an "internal error" and an incomplete set of pages. It would have been nice to get a more informative error message, but I found an Adobe Technote recommending repairing permissions. This

  • Motion XML to opticalflow slow

    Hello, It`s possible to write a Motion XML and make it like a "filter" in Final Cut Pro to change the frame blending on a clip to OpticalFlow? I`m asking this because when you do a slowmotion (change speed) on a clip in Final Cut Pro sequence and it