aspose file tools*
The moose likes Beginning Java and the fly likes comparing two tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "comparing two tables" Watch "comparing two tables" New topic
Author

comparing two tables

sina sinchen
Greenhorn

Joined: May 24, 2004
Posts: 9
Hello one and all,

I have two tables like

I have to compare the table I with the table II and assign the values of column II of table II to table I.For example,BR 1101 is found in table I and aslo in table II so it grabs the value of TUO-881 and write it in a new file which looks like:


I tried to read the files using IO but its getting very complicated.could u pls suggest which would be a better approach.I need to compare such tables for a huge data more than 5000 datas in a file.
[ June 04, 2004: Message edited by: Dirk Schreckmann ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10925
    
  12

Do you know for a fact that BR0-1101 will only occur in the second table once?

read table 2 into a hashmap, using the first field as your key.

then, as you read each line of the second file, check to see if that key is in the hashmap. if so, pull out the data, and write it to the new output.

if you don't find it, then you can either write out the two fields you have from table I, or ignore it - whichever you need to do.

does that make any sense?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comparing two tables
 
Similar Threads
reading two files and extracting the info re from other file
Problem with the o/p of the program
To have table side by side in HTML
org.apache.axis2.AxisFault exception - Operation not Found
org.apache.axis2.AxisFault exception - Operation not Found