PDA

View Full Version : Compare 2 txt documents



saban
03-12-2008, 02:32 PM
I would like to compare 2 different txt files and, add the words from 1st document that are missing in 2nd document, into 2nd document

1. Compare two document doc1 and doc2:

check doc1 for every word and compare to doc2
if word from doc1 is found in doc2 then leave it alone, but if a word
from doc1 is not found in doc2 then add it at the end of doc2What would be the best way to do something like this

Thnx

fumei
03-13-2008, 09:44 AM
Define your requirements in more detail.

One word at a time? Found anywhere? Is the order significant?

saban
03-13-2008, 12:58 PM
2 documents 1.txt and 2.txt :

I want to add in document 1.txt all the entries from 2.txt except the ones that are already in document 1.txt

fumei
03-13-2008, 01:16 PM
Can be done, but I will let someone else help. I am tired of asking questions that do not get answered. It is too much of a strain to get you to spec things out precisely.

saban
03-15-2008, 05:22 PM
2 documents 1.txt and 2.txt :

I want to add in document 1.txt all the entries from 2.txt except the ones that are already in document 1.txt


but what is unclear about this ???

fumei
03-16-2008, 08:19 PM
1. how do I know if there are, or are not, repeated strings? You could have - but did not - state that there will never be repeated strings.

2. "entries" is a meaningless term. Do you mean text? Do you mean paragraphs? Will there ever be paragraphs with more than one word? Why do I ask? Because if there is ONLY ever one word per paragraph, then you can use the Paragraph object. If there are more than one word per paragraph, then you can't. Why is that significant? Because, if you use VBA to deal with "words", then you have to deal with how VBA - not Word - deals with "words".

To VBA, the string (as a paragraph):

This is some text.

contains SIX words.

saban

If the above is a paragraph - i.e. "saban" and a paragraph mark - then it is (to VBA) TWO words.

3. "add"....sure, your Result document is (obviously) the way you want it, but "add" could mean anything. Added right after the preceding word...OR...add it as a new paragraph. Your Result document has it as new paragraphs, but you do not explicitly state that is your requirement.

4. One document has a "empty" paragraph, the Result does not. Is THAT a requirement?

5. I asked a direct question - "Is the order significant?" Is it so hard to actually answer? say..."No, the order is not significant."

But you don't answer.

Depending on your requirements AND the actual conditions, this is not terribly difficult to do. It is, as usual, simply a matter of solid robust logic.

fumei
03-16-2008, 08:30 PM
BTW: hint, run your logic testing so you are checking doc2 against doc1...not the other way around.

saban
03-18-2008, 02:01 PM
sorry about that

the entries I am interesting in are paragraphs

there are names in documents 1 and 2



ex. document 1

saban saulic
mirza mizanovic
janez drex
siptar john

and document 2:

ex. document 1



saban saulic
mirza mizanovic
janez drex
siptar john
ivan cankar
josip broz


So now I would like
ivan cankar
josip broz

added below the existing names in document 1

the order is not significant

And sorry again for lack of information, wont happen again

Alphacsulb
03-20-2008, 02:47 PM
Difcompare

from download website.

mdmackillop
03-21-2008, 09:08 AM
Difcompare

from download website.

:doh: