Welcome Guest.   Make a donation to an author on the site September 22, 2014, 07:10:21 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2010! Download 24 custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Merge .txt files but with the copy/paste method  (Read 6513 times)
alogoc
Supporting Member
**
Posts: 19


see users location on a map View Profile Give some DonationCredits to this forum member
« on: September 05, 2009, 08:43:30 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....

* 187-539.txt (74.47 KB - downloaded 178 times.)
* 706-507.txt (5.96 KB - downloaded 180 times.)
* 188-540.txt (28.08 KB - downloaded 181 times.)
Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: September 05, 2009, 08:58:17 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 tongue), should be able to save all of the files in utf-8, which would solve that problem too.
Logged

alogoc
Supporting Member
**
Posts: 19


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: September 05, 2009, 09:00:02 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:45 AM by alogoc » Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: September 05, 2009, 09:04:15 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 Sad
Logged

skwire
Moderator
*****
Posts: 4,078



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: September 05, 2009, 09:42:44 AM »

Is all that you would like to do is concatenate one file to the next?
Logged

jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: September 05, 2009, 10:22:28 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)
Logged

skwire
Moderator
*****
Posts: 4,078



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: September 05, 2009, 10:29:09 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
Logged

jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: September 05, 2009, 10:35:43 AM »

Hey, that's a cool trick, thanks skywire cheesy
Logged

Ampa
Charter Member
***
Posts: 589


I am cute ;)

View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: September 05, 2009, 11:10:15 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:22 AM by Ampa » Logged
alogoc
Supporting Member
**
Posts: 19


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #9 on: September 05, 2009, 12:29:21 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 Sad
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:27 PM by alogoc » Logged
alogoc
Supporting Member
**
Posts: 19


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #10 on: September 05, 2009, 12:34:43 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 Sad

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?
Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: September 05, 2009, 05:08:56 PM »

It's quite easy.. Just open a console in the folder where you have your files, and type the following command:
[copy or print]
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 smiley
« Last Edit: September 05, 2009, 05:11:07 PM by jgpaiva » Logged

jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: September 05, 2009, 05:13:46 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?
Logged

rjbull
Charter Member
***
Posts: 2,758

View Profile Give some DonationCredits to this forum member
« Reply #13 on: September 06, 2009, 10:39:30 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.
Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #14 on: September 06, 2009, 10:54:57 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!
Logged

MilesAhead
Member
**
Posts: 4,844



View Profile WWW Give some DonationCredits to this forum member
« Reply #15 on: September 06, 2009, 12:10:48 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.
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #16 on: September 06, 2009, 03:29:30 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.
Quote
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?

Quote
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
Logged
Darwin
Charter Member
***
Posts: 6,979



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #17 on: September 06, 2009, 03:52:08 PM »

I might be out in left field here, but metapad has some very useful search and replace features. It's also FOSS  Thmbsup

Logged

"Some people have a way with words, other people,... oh... have not way" - Steve Martin
MilesAhead
Member
**
Posts: 4,844



View Profile WWW Give some DonationCredits to this forum member
« Reply #18 on: September 06, 2009, 03:53:20 PM »

btw for unix utility ports you can try these.  They worked for me on XP SP2

http://unxutils.sourceforge.net/
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
MilesAhead
Member
**
Posts: 4,844



View Profile WWW Give some DonationCredits to this forum member
« Reply #19 on: September 06, 2009, 03:56:14 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:45 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
alogoc
Supporting Member
**
Posts: 19


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #20 on: September 08, 2009, 03:42:24 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!
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.049s | Server load: 0.05 ]