• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing lines in two different text files and modifying d target line's last column  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use the first column of each line in File 2 as a criteria to check if such line exist in file 1..if it does, change the last column in File 1 (yes, no) of such line to 'maybe'.


File 1
6130124,860847,9,9,4,9,e,6,2,S, yes
6150744,194559,7,7,4,9,e,6,2,S,no
6065543,511353,5,4,4,9,e,6,2,S,no
8419554,261221,6,6,2,18,a,7,1,S,yes
8190063,144544,5,5,2,18,a,7,1,S,no
8276868,285387,4,4,2,18,a,7,1,S,no
625541,233528,2,2,4,9,a,3,1,N,yes
676477,138280,2,2,4,9,a,3,1,N,no
628496,59404,2,2,4,9,a,3,1,N,no

File 2 ( a subset of File 1)
6130124,860847,9,9,4,9,e,6,2,S, yes
6150744,194559,7,7,4,9,e,6,2,S,no
8276868,285387,4,4,2,18,a,7,1,S,no
625541,233528,2,2,4,9,a,3,1,N,yes

That means...file 1 will be printed as :
6130124,860847,9,9,4,9,e,6,2,S, maybe
6150744,194559,7,7,4,9,e,6,2,S, maybe
6065543,511353,5,4,4,9,e,6,2,S,no
8419554,261221,6,6,2,18,a,7,1,S,yes
8190063,144544,5,5,2,18,a,7,1,S,no
8276868,285387,4,4,2,18,a,7,1,S,maybe
625541,233528,2,2,4,9,a,3,1,N,mabe
676477,138280,2,2,4,9,a,3,1,N,no
628496,59404,2,2,4,9,a,3,1,N,no


This is what I have done so far


 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What problems are you running into?

Also, the code you posted doesn't compile. (I know we are banging on you about the code, but it's important.)
 
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What your program does?
What it is meant to do?

You have one method "main", its purpose is to start your program. It seems you just scrambled all your code to the main and made a big mess.
What this "b" means prior the "while" loop?

What variable "ID" represents?
What variable "temp" represents?
What this line of code does? What line2 means?

Code indentation and formatting are still terrible.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!