Merging two files in Notepad

2019-07-25 12:07发布

Hi i have two long files both 30k lines long. Is there any way of merging them like that in Notepad++ or using other software?

1st line from 1st file: 1st line from second file

4条回答
做自己的国王
2楼-- · 2019-07-25 12:47

For decades there have existed a command to do exactly this, paste. Example:

$ cat > file1
one
two
three
$ cat > file2
1
2
3
$ paste file1 file2
one     1
two     2
three   3
$

The free gnu version is currently part of coreutils, which I think is simplest to install via cygwin. If you need the separator to be exactly colon+space you can just pipe paste's output through sed 's/\t/: /'.

查看更多
该账号已被封号
3楼-- · 2019-07-25 12:49

If you happen to have python on your computer, using itertools you can merge both files. Keep in mind that if one file ends before the other, whichever file keeps going will continue to put their lines into the output file.

from itertoools import izip
with open("outputfile.txt", 'w') as output:
    with open ("firstfile.txt") as f1 , with open ("secondfile.txt") as f2:
    for file1,file2 in zip(f1,f2):
        output.write(f1)
        output.write(f2)
查看更多
迷人小祖宗
4楼-- · 2019-07-25 12:50

this is not possible in Notepad as far as i know, so your best bet is Notepad++. is there a reason why you don't wanna use Notepad++?

EDIT: I see, i deserve that -rep :P sorry for not reading correctly.

What you do in Notepad++ is:
1. open Notepad++ and navigate to Plugins > Plugin Manager > Show Plugin Manager
2. look for and Check "Compare"
3. click "Install"

now what you do is you open your first file in Notepad++. after that, you open your second files inside the same window of Notepad++ and drag the second file to the middle of Notepad++ (so click and drag the second document to the middle of Notepad++) once you release, it will ask you what to do. Click on "Move next to eachother"

after you have done that, you can now click Plugin > Compare > Compare. this will comapre the 2 files and give you exactly whats different between them.

Sorry for putting the answer quickly without reading more carefully.

查看更多
爷、活的狠高调
5楼-- · 2019-07-25 12:59

Here is a possible solution using Excel:

1.) Open the first file with Excel (all the text should be in one column)

2.) Open the second file with Excel (all the text should be in one column)

3.) Go back to your first file and add a : to every row of the second column

4.) Copy the first column of the second file and paste it to the third row of the first file

5.) Save the combined file as *.txt file

查看更多
登录 后发表回答