Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing two tables

 
sina sinchen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12098
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic