Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sorry for my rough English, I try to visualize my question.

I have two lists of words, one per line, each list in a separate file:

File 1:

white
fehér
green
zöld
red
piros

File 2:

white
blanco
green
verde
red
roja

I need to combine these lists, removing any duplicates and create a new file containing the following:

fehér
blanco
zöld
verde
piros
roja

I am a newbie with Notepad++ and can't work out this problem.

share|improve this question

migrated from stackoverflow.com Oct 11 '12 at 19:33

This question came from our site for professional and enthusiast programmers.

    
Are you using the built-in commands of Notepad++ or another programming language? It also looks like it you're stripping out any duplicates from the list as well as merging other lines. –  StuperUser Oct 11 '12 at 17:27
    
Thanks for the replies. Sorry for the wrong posting place, should I copy my problem there or will it be moved to superuser? –  Kalman Mettler Oct 11 '12 at 17:33
    
@StuperUser: I'm not familiar with regex nor with programming languages. "It also looks like it you're stripping out any duplicates from the list as well as merging other lines" Yes, I'd like to strip out the duplicates –  Kalman Mettler Oct 11 '12 at 17:36
    
No worries Kalman. Since you're trying to solve your problem with Notepad++ rather than another programming language, it will probably be answered on Superuser, and you won't need to create a copy on superuser, it will be migrated automatically. Try searching that site for more information that might help you. –  StuperUser Oct 11 '12 at 17:40
add comment

2 Answers

This looks like a duplicate question over at stackoverflow: http://stackoverflow.com/questions/3958350/removing-duplicate-rows-in-notepad

The main solution is to install the TextFX plugin. Then put all of your content in one file and use TextFX to both sort and remove duplicates.

share|improve this answer
add comment

As I understand this, you have two translation files, from english to hungarian and from english to italian(?). And what you want is to use english as key to combine the italian and hungarian one, correct?

My solution only works if you don't have many files to convert but where it is feasible to do the steps by hand. It is important, that you check that the alternating languages pattern is true for every pair in both files.

At first, open both files in Notepadd++ and open Find/Replace by hitting CTRL-F or Edit->Find/Replace... Then click the replace-tab. Select the regular expression search method and enter the following for find:

^(.*)\r\n(.*)$

With find next you can check if it is selecting two lines at once.

For replace enter:

\1 \2

Replace the cursor to the beginning of the file and try some clicks at "Find" and "Replace". It should write the words from to consecutive lines in one, separated with a space. Do this for both files, as mentioned. You now have the key values (if I understand the problem correctly) in both files in the first column. If the first column in both files now contain the exact same words in their respective lines you can continue. They should look like this:

white fehér
green zöld
red piros

white blanco
green verde
red roja

You the that the first column is identical in both files. You now use the column mode (pressing alt while selecting anything from the second file). Select anything in the second file. Press CTRL-C (Edit-> copy). Open the first one, and insert so many spaces after the end of the first line that it exceeds the longest line in that file. Then add the contents from the second one by hitting CTRL-V. Should look like this:

white fehér white blanco
green zöld green verde
red piros red roja

Now you have to remove the keys by find/replace. Find:

^([^ ]*) ([^ ]*) *(.*) (.*)$

replace:

\2\r\n\4

Should now look like:

fehér
blanco
zöld
verde
piros
roja

Voila. Hope that helped!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.