Merging two text files

Author
Discussion

ArsE92

Original Poster:

21,013 posts

187 months

Thursday 18th December 2014
quotequote all
Chaps

I need to merge two very similar text files into one output file on a regular basis (on Windows), and I need to automate it. Usually this would be pretty straight-forward using basic copy commands but I need to make a few changes to the final output.

Both files have a similar header, but I only need to keep one of them.

Both files have a record count at the end, but I need to discard one and make the final one correct.

Not so easy now!

So, in pseudo code, I think I need to:

copy file1 to variable1
copy file2 to variable2
concatenate variable1 & variable2 into variable3
find and delete the second instance of the header in variable3
find and delete the first record count in variable3
find and delete the second record count in variable3
count records and create a new record count line in variable3
write variable3 to output.txt
profit

It's been a while since I've done any scripting but I used to be pretty good with batch files and I'm picking up a bit of Powershell as I go along.

Any thoughts on what I can best use and how I can achieve the above? I could probably spin up a Linux VM just for this if it really was the best solution, but I'm not great with Linux.

Thanks in advance

ArsE92

Original Poster:

21,013 posts

187 months

Friday 19th December 2014
quotequote all
Thanks - just downloading gnuwin32 now and will have a play this weekend. smile

ArsE92

Original Poster:

21,013 posts

187 months

Friday 19th December 2014
quotequote all
laugh

ArsE92

Original Poster:

21,013 posts

187 months

Friday 19th December 2014
quotequote all
Driller said:
So it's a group effort eh? Nice.

You post up an idea and someone just comes along and pisses on it.

You're rude and childish however many there are of you.

Oh and Mr Arse 75 months and 20,000 odd posts, it's all very clear laugh

Edited by Driller on Friday 19th December 22:29
What's the matter with you? Good grief.

ArsE92

Original Poster:

21,013 posts

187 months

Friday 19th December 2014
quotequote all
Driller said:
What's the matter with me, have you no sense of etiquette?

What exactly does "Has Anyone Really Been Far Even as Decided to Use Even Go Want to do Look More Like" mean?
Well you posted it above.

ArsE92

Original Poster:

21,013 posts

187 months

Saturday 20th December 2014
quotequote all
Driller said:
littleredrooster said:
Driller said:
I posted asking people's opinion on something...
No you didn't, you posted this:
driller said:
Has Anyone Really Been Far Even as Decided to Use Even Go Want to do Look More Like?
That is what you actually posted. I don't think any of us knows what it means so please don't go on an uncalled-for rant.
http://www.pistonheads.com/gassing/topic.asp?h=0&a...

I thought it was clear that this would have been from another thread, so the link should help you.

Edited by Driller on Saturday 20th December 12:37
Driller, seriously. You posted something in The Lounge and I made a throwaway comment. Are you really that sensitive that you felt the need to browse my profile and come and comment on another thread that I'd started in another sub-forum?

Do you just want me to apologise? I'm sorry. Now will you go away?

ArsE92

Original Poster:

21,013 posts

187 months

Saturday 20th December 2014
quotequote all
TheEnd said:
Besides I've been further even more decided to used even go need to do more as anyone can. Can your really be far even as decided half as much to use go wish for that? My guess is that when one really been far even as decided once to use even go want, it is then that he has really been far even as decided to use even go want to do more like. It's common sense, bro.

I hope that helps.
laugh Exactly

ArsE92

Original Poster:

21,013 posts

187 months

Saturday 20th December 2014
quotequote all
Driller said:
TonyRPH said:
And here I was, thinking that Driller had been overcome with Novocaine. wobble

wavey Driller.
Heh, heh, hello Tony smile

mike9009 said:
ArseDriller having a lovers tiff? Kiss and make up lads, life is too short....
You're right you know.

It's the festive season Arse (there's no other way of putting it!) so cheers to you, no hard feelings beer

Edited by Driller on Saturday 20th December 18:12
beer

ArsE92

Original Poster:

21,013 posts

187 months

Friday 9th January 2015
quotequote all
eltawater said:
So was this any good to you in the end?
I downloaded all the tools and since then I've not had chance to have another look!

It's something that will need to be done monthly. So I did December manually.

I will get a look at some point.

Cheers