topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 1:23 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Merge .txt files but with the copy/paste method  (Read 16678 times)

alogoc

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 19
    • View Profile
    • Donate to Member
Merge .txt files but with the copy/paste method
« on: September 05, 2009, 08:43 AM »
Hello,i used several programs to merge .txt files.
The final .txt have many problems,for example language is messed up (Greek),or the text doesn't go where it has to be.Generally is messed up....

Is the a way to be done with the copy/paste method?Like a macro or something?I am very confused...

Here are some examples of the text that need to merged

If anyone can help,please....

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #1 on: September 05, 2009, 08:58 AM »
From what I understand, there's a problem with those files: they don't keep the same space between columns.
Two of them use 7 spaces, while the other one uses a tab.
That's probably why the formating gets messed up.

I recommend you first replace every tab with a space (any text editor with search+replace should do this pretty easily), and then try to merge them. That should get you better results.
As for the language.. Maybe each txt has its own encoding. If they do, good editors (I use vim, but if you're not used to it, don't bother with learning :P), should be able to save all of the files in utf-8, which would solve that problem too.

alogoc

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 19
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #2 on: September 05, 2009, 09:00 AM »
Damn...that's too much time consuming.Is there an "easy way" to do this?It's like 600 files...
« Last Edit: September 05, 2009, 09:02 AM by alogoc »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #3 on: September 05, 2009, 09:04 AM »
To be honest, I can't make a program to do it for you.
Maybe Drag and Drop Robot could help.
In linux, I'd use SED to replace the tabs with spaces. I don't know of any similar tool in windows, though :(

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #4 on: September 05, 2009, 09:42 AM »
Is all that you would like to do is concatenate one file to the next?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #5 on: September 05, 2009, 10:22 AM »
skwire: Yes, the problem is that the files are not all in the same format, from what I understand.

He'd require changing tabs to spaces, and setting all files on the same encoding (I'd suggest utf-8)

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #6 on: September 05, 2009, 10:29 AM »
Understood, and yes, I agree about the files he provided; they are inconsistent.  However, if all he wants to do is join one file to the next, he can simply do  something like this on the commandline:

copy file1.txt + file2.txt + file3.txt newfile.txt

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #7 on: September 05, 2009, 10:35 AM »
Hey, that's a cool trick, thanks skywire :D

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #8 on: September 05, 2009, 11:10 AM »
You make want to try CSVed for handling files of this type.

Update:Just tried CSVed and it doesn't like the files (guess I should learn more about CSV files!)



However Excel will do the job very nicely - it imports text files and gives numerous options for delimiting columns.
« Last Edit: September 05, 2009, 11:22 AM by Ampa »

alogoc

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 19
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #9 on: September 05, 2009, 12:29 PM »
Hey there,thanks for answering,i want to make them one,to count how many 1.000 there are (quantity) though in some files there are 2,3,5 etc.In a few words i want to make an assortment.

The idea was to import them in excel and simply make a sum...but luck had other plans for me :(
I made them one but the cells don't fit right...i don't know how else to do this...i am really confused


And it's 600 files...my computer is going to crash if i open them all.And then i'll have to make them all in one excel...damn i'm in such a mess
« Last Edit: September 05, 2009, 12:31 PM by alogoc »

alogoc

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 19
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #10 on: September 05, 2009, 12:34 PM »
To be honest, I can't make a program to do it for you.
Maybe Drag and Drop Robot could help.
In linux, I'd use SED to replace the tabs with spaces. I don't know of any similar tool in windows, though :(

Hey jgpaiva,i run linux (though i'm a noob still)...how difficult is this to make this?With SED?Does it need some further knowledge...and skills of course?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #11 on: September 05, 2009, 05:08 PM »
It's quite easy.. Just open a console in the folder where you have your files, and type the following command:
cat *.txt | sed "s/\s\+/,/g" > output.out
That'll read all the txts in the folder, pass them to sed, which then replaces consecutive blank spaces with a comma, and then outputs the result of this command to a file named output.out.

It still does not fix the problem with the different encodings, but it might be a first step in the right direction.


ps: DON'T name the output with the .txt extension, or it'll be read by the script and it'll enter an infinite loop :)
« Last Edit: September 05, 2009, 05:11 PM by jgpaiva »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #12 on: September 05, 2009, 05:13 PM »
By closely observing the data, I can see you have files with different number of columns.. That'll make the problem even more difficult. Which column exactly do you want to sum?

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #13 on: September 06, 2009, 10:39 AM »
In linux, I'd use SED to replace the tabs with spaces. I don't know of any similar tool in windows, though
jgpaiva, was that a grammatical error?  Surely you know there are Windows ports of SED? Alternatively,
freeware WinGUI search-and-replace apps include BKReplacem and HandyFile Find and Replace (HFFR) last free version.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #14 on: September 06, 2009, 10:54 AM »
Actually, I didn't know there are ports of sed for windows (except for cygwin, which is a giant nuisance).
Thanks for the info, rjbull!

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #15 on: September 06, 2009, 12:10 PM »
There are 32 bit ports of Linux programs like sed and awk that are stand-alone exe. Or if you are into regular expressions you can use either Perl or Ruby. There has to be programs for Windows that remove the tabs and fill with the calculated number of spaces.  Try Softpedia.com and the other big freeware/shareware download sites.  Also try Sourceforge.net for the same.  Include "win32" in the search on Sourceforge.  That should narrow the results to mostly Windows programs.

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #16 on: September 06, 2009, 03:29 PM »
i want to make them one,to count how many 1.000 there are (quantity) though in some files there are 2,3,5 etc.In a few words i want to make an assortment.
The idea was to import them in excel and simply make a sum...
Be more specific.  What exact info would you want from the three .txt files?  Do you need to see one concatenated file with all the columns adjusted and lined up?  Or do you want that simply to get some totals or other stats, and if so is it just a few things and is it a one-time chore?

And it's 600 files...my computer is going to crash if i open them all.And then i'll have to make them all in one excel...damn i'm in such a mess
If you really have to process each file separately, 600 is worth spending the time to automate the process (personally at this point I'd be asking myself how badly I really needed this info).  

You could use VBA code in Excel to process each line of each file.  How complicated this gets depends on what you have to start with, and what you want to end up with.  



But

Darwin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,984
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #17 on: September 06, 2009, 03:52 PM »
I might be out in left field here, but metapad has some very useful search and replace features. It's also FOSS  :Thmbsup:


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #18 on: September 06, 2009, 03:53 PM »
btw for unix utility ports you can try these.  They worked for me on XP SP2

http://unxutils.sourceforge.net/

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #19 on: September 06, 2009, 03:56 PM »
I might be out in left field here, but metapad has some very useful search and replace features. It's also FOSS  :Thmbsup:



Plus there are some editors like the one used in Win32 edition of Python that will automatically convert tabs to the calculated number of spaces.. I'm not familiar with MetaPad but for bulk a stream editor like sed or tr might be simpler.. or even awk.  The tab=>spaces is likely a one-liner you can find online on a forum somewhere.

edit: a casual google found a few but most were for reformatting/indenting source code and make some assumptions(like that the file has some C or scripting language text.)  There must be some for plain text if you look hard enough.

« Last Edit: September 06, 2009, 03:59 PM by MilesAhead »

alogoc

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 19
    • View Profile
    • Donate to Member
Re: Merge .txt files but with the copy/paste method
« Reply #20 on: September 08, 2009, 03:42 AM »
Hello all,thanks for trying to help me out!Really appreciated it!

Well the solution was like that :

I used txt collector,merged them but also it told wich files got error.
So the error files (was lucky within my bad luck) was like 40.So i imported them manually in Excel.Then imported the merged txt and summed them manually.

It was an easy solution,and not much time wasting.Though if i had many error files the situation would be a lot worse...

Anyway,thanks for trying help!Really appreciate it!