Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

807589Nov 24 2008 — edited Nov 24 2008
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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2008
Added on Nov 24 2008
2 comments
1,814 views