Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to merge two very large lists together.

File1.txt

  • Washington|
  • Ohio|
  • Dublin|
  • London|
  • Milan|

File2.txt

  • Greg
  • Tom
  • Paul
  • Sharon
  • Bill

Output.txt

  • Washington|Greg
  • Ohio|Tom
  • Dublin|Paul
  • London|Sharon
  • Milan|Bill

How can I do that in Windows?

share|improve this question
    
Pretty much any program that compares two files and allows you to merge the differences can do something like this. – Ramhound Feb 15 '13 at 14:25
    
@Ramhound All the programs like that I have used will let you overwrite one line with another, but I've never run into a program that will append lines together, I could be wrong though, and I always like to learn new things, could you expand your comment into an answer explaining how to do this? – David Feb 15 '13 at 14:36
    
@Ramhound most merge programs just overwrite the differences rather than appending. – Ninja2k Feb 15 '13 at 14:42
1  
See: Merge 2 txt files in a single tab delimited file in batch. In Unix, you'd have paste for that. – slhck Feb 15 '13 at 14:50

I got a working solution. Pasted the rows to Excel and exported it as text file, rather than an XLS file.

share|improve this answer

If it's not too much data you should be able to do this with something like MS Office or LibreOffice. Load the two text files, cut n paste them into different columns in a spreadsheet (Col A for file 1, col b for file 2) then cut and paste (special, raw text) back into a text doc.

It's not pretty but it will work with some manual work on your part.

share|improve this answer
    
I am afraid its 10K of data :( – Ninja2k Feb 15 '13 at 14:46

You can do that with the paste command line utility that comes with my Hamilton C shell. If this is a one-time thing, you'll be happy with the free version of my C shell. Full disclosure: I'm the author.

paste -d \0 File1.txt File2.txt > Output.txt

Here's what it looks like on your data:

176 C% cat File1.txt
Washington|
Ohio|
Dublin|
London|
Milan|
177 C% cat File2.txt
Greg
Tom
Paul
Sharon
Bill
178 C% paste -d \0 File1.txt File2.txt
Washington|Greg
Ohio|Tom
Dublin|Paul
London|Sharon
Milan|Bill

Cygwin also includes a paste but to use that one, you'll need to ensure that all the lines end with only a newline (\n) character, Unix-style, not a carriage return-newline (\r\n) combination Windows-style or you'll get this:

179 C% \cygwin\bin\paste -d \0 File1.txt File2.txt
Gregington|
Tomo|
Paulin|
Sharon|
Billn|

(The Cygwin paste treats the \r as an ordinary character. On the screen, it moves the cursor to the beginning of the line, overwriting what was there.)

share|improve this answer

command line, var 1:

powershell $f1=gc File1.txt;$f2=gc File2.txt;for($i=0;$i-lt$f1.length;$i++){$f1[$i]+$f2[$i]}>Output.txt

command line, var 2:

powershell $f1=gc File1.txt;$f2=gc File2.txt;for($i=0;$i-lt$f1.length;++$i){$f1[$i]+$f2[$i]^>^>Output.txt}

paste-d.ps1

$f1=gc File1.txt;$f2=gc File2.txt;for($i=0;$i-lt$f1.length;++$i){$f1[$i]+$f2[$i]>>Output.txt}
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .