I want to merge the content of two files but I don't know if it's possible, Please help
darklinkpower last edited by
I have two files that differ in content and I want to make a third one that combines both but I don’t know if it’s possible. The lines look something like this:
sametext <text><![line a[line b, line c, line d, A1, A2, A3]]></text> sametext
sametext <text><![line a[line b, line c, line d, B1, B2, B3]]></text> sametext
And I want to make a third file that looks like this:
sametext <text><![line a[line b, line c, line d, A1, A2, A3, B1, B2, B3]]></text> sametext
Forgive me if this is an easy task but sadly I don’t have the knowledge to do it so I figured I could ask here if it’s possible. Thanks in advance.
darklinkpower last edited by darklinkpower
Said text files contain hundreds of lines like this so doing it manually would be very difficult, that’s why I’m looking if there can be a way to do it with n++. I also forgot to add that the lines differ slightly, changing the content of the different line
<text><![line a[word, ads, wdwd , wsws, dfdf, dff]]></text>
For the next line, while it follows the same structure, changes in the content after “line a[” but end in the same "]]></text> ". So basically what I want is a way to fuse the differences together of the lines that differ but I don’t know if it’s possible since there’s not a clear pattern other than the estructure of the lines
gurikbal singh last edited by gurikbal singh
after do as given suggest
PeterJones last edited by
This sounds very similar to the recent “How to merge” topic. You may be able to use or modify-for-use the regex solution solution that @guy038 posted or the PythonScript solution that I posted. They may have to be tweaked slightly for your exact circumstances, but they are a good starting point.
If you get stuck while trying to modify them to meet your needs, let us know what you’ve tried, and what parts are giving you difficulty, and we may be able to help you get unstuck.
darklinkpower last edited by
thanks for the help guys
@gurikbal-singh nice idea, I didn’t know you could select multiple lines that way. Please correct me if I’m wrong but this could only work if the line lenghts are in the same place right? because if the text that I want to copy don’t align then I will copy text that I don’t want to
@PeterJones I don’t think it’s the same issue. There he has 2 list that he wants to merge, without any extra data that he wants to get rid of. What I want to do is just copy some data of the second file, not all.
After googling around I found what you can use expressions to match text and I came up with this that matches the text I want to copy to the other file, but I don’t know how to copy it to the other file. The files are xml files
Here’s what I could come with:
PeterJones last edited by PeterJones
I don’t think it’s the same issue.
I didn’t say it was the same. I said it sounds similar. Good job on coming up with a regex that gets you partway there.
The problem you see now is that it looks like more of a problem than a simple regex will solve. (That said, @guy038 can work magic with his regex and multi-step regex.)
I had meant for the script linked in the other topic to give you a starting point, because I had thought I’d used just normal line-by-line reading in one and writing in the other. But since it wants to merge every line in the second onto N copies of every line in the first, I used some tricks, which eliminated the logic which would have helped you; sorry.
Off the top of my head, the top-level description would be “for each of the matches in the second file (and PythonScript has access to a similar regular expression library, so finding those matches won’t be too difficult), grab the right portion of the matching text, and insert it into the correct line of the first file.” Implementing that in more detail is what programmers get paid for. For some problems, one of us in the Community occasionally writes the script for free (usually if we’re interested in the problem or see that we can apply it generally to a task that we have to do as well, or if it looks like we could get it in a brief amount of time), but that doesn’t always happen (this isn’t a we-guarantee-we’ll-write-your-code-for-free forum, after all). And this one looks to me to be a longer problem than I’m likely to have time for in the forseeable future. Maybe it’ll catch someone else’s eye, though.
if you were to come up with a rough attempt of a PythonScript solution, that got close but not exactly what you wanted, and posted it here, there might be more people who would have the time to help point you in the right direction, or show you what Notepad+±specific features of PythonScript that could help.
Sorry that I don’t offer more of a solution, but while Notepad++ is powerful, there are some things that are better handled with actual programming, and you may have hit one (unless @guy038 proves me wrong).