Jump to content
Sign in to follow this  
HeavenlyDemon

merge 2 text files

Recommended Posts

HeavenlyDemon

Hello forum

I have 2 text files

textfile1.txt

textfile2.txt

textfile1.txt

1 text
2 text
3 text
[b]4 line[/b]
5 text
6 text
[b]7 line[/b]
8 text
9 text
10 text
[b]11 line[/b]

textfile2.txt

[b]1 text
2 text
3 text[/b]
4 line
[b]5 text
6 text[/b]
7 line
[b]8 text
9 text
10 text[/b]
11 line

the files have 600 or more lines

i need to copy the text between line from textfile2.txt

and replace line in textfile1.txt

i am realy stuck here

Share this post


Link to post
Share on other sites
kylomas

HD,

You'll get better response if you post portions of each text file and explain your purpose more clearly.

This

i need to copy the text between line from textfile2.txt

and replace line in textfile1.txt

does not make sense to me.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
somdcomputerguy
_FileReadToArray should get you started, and put the end in sight..

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
HeavenlyDemon

HD,

You'll get better response if you post portions of each text file and explain your purpose more clearly.

This

does not make sense to me.

kylomas

I know i get better response but the files are workrelated and i am unable to post even a line from them.

il make a somewhat similar file and post it

textfile1.txt

1 this is a text
2 this is another text
3 LINE1
4 this is the forth text
5 LINE2
6 text number is 6
7 text number is 7
8 text number is 8
9 text number is 9
10 LINE3
.....

textfile2.txt

LINE1
1 this text goes after line1
2 this also goes there
3 the same
4 text in line1
LINE2
1 this text goes after line2
2 this also goes after line2
3 the same
LINE3
.....

_FileReadToArray should get you started, and put the end in sight..

Can you please explayen in details ? Edited by HeavenlyDemon

Share this post


Link to post
Share on other sites
BrewManNH

What should the result of the copying process look like once you get it working? If we know what you want to get to, we can direct the steps better.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
HeavenlyDemon

result.txt

1 this is a text
2 this is another text

1 this text goes after line1
2 this also goes there
3 the same
4 text in line1

4 this is the forth text

1 this text goes after line2
2 this also goes after line2
3 the same

6 text number is 6
7 text number is 7
8 text number is 8
9 text number is 9
10 LINE3
...

Share this post


Link to post
Share on other sites
kylomas

HD,

What happens to "LINE1" and "LINE2"?

kylomas

Never mind, I think I see the pattern. Does the text from file 2 always folow the text from file 1 in the result file?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
BrewManNH

Do the numbers at the start of the line have some sense to them? Because they're not in order in the results.txt, and trying to figure out what is supposed to be there is important.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
HeavenlyDemon

HD,

What happens to "LINE1" and "LINE2"?

kylomas

Never mind, I think I see the pattern. Does the text from file 2 always folow the text from file 1 in the result file?

The only connection between file1 and file 2 is the LINEx

Its there i know i have to insert the text from file2

Do the numbers at the start of the line have some sense to them? Because they're not in order in the results.txt, and trying to figure out what is supposed to be there is important.

they have no importance

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×