Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read and compare two files

Status
Not open for further replies.

joda124

Technical User
Jan 17, 2008
9
IT
Good Morning !!
I have two files, the first file contains some strings for example "Name", the second file contains "name" and "Surname".
Problem:
1) Read every string "Name" on File 1
2) Read every string "Name" on File 2
3) Compare every string value in file 1 with every string value on file 2 or eventually if string "Name" on file 1 is equal to string "Name" on file 2 read correspondent string "Surname" and write this value on third file and go to the next string.

Can you help me to translate this steps in aspect.

Thank you !

Best Regards / Joda124
 
Why don't you show us what you got so far in your script,
and we'll guide you in the right direction?

HTH
 
i'm not a script ready at this moment i need some information, for example how i can compare two string in two different files so i can copy one of these in a third files.

Thank you for your attention !!!
 
I have a couple scripts on the samples page of my site ( that users here submitted to me earlier that might get you started. Just search for "compare" in the page and you should find two hits. You'll need to modify them a bit such that all of file 2 is read and compared to the line in the first file, then the second line from the first file is read and compared to all lines in file 2, and so forth.

 
Dear Knob, thank you so much for your attention.
I would like to do this:
Open the first file, read every row and search and extract if found a string value (for example string 1), open the second file and read every row, when string value of the first file is found, extract a specific string in the same row and copy it in a third file. I try to write an aspect script similar to file_compare script in your page but i have problem to perform action indicated above.

Your help will be appreciated. Thank you


Joda124
 
You would use strfind to look for the string and then a command like strextract, strtok, or similar (depending on what you data in the second file looks like) to pull out the string you need.

What does your current script look like and what is your current blocking point?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top