Joining txt files?

Discussion in 'OT Technology' started by OFI, Feb 11, 2009.

  1. OFI

    OFI New Member

    Joined:
    Apr 6, 2006
    Messages:
    52,607
    Likes Received:
    0
    Location:
    Wet Wales
    Is there any way I can join a bunch of txt files together?

    I have a bunch of txt files each with a large column of data in and i'd like them to be joined one after the other. Any way to automate this rather than going mad with copy and paste?

    :bigthumb:
     
  2. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    i'm guessing this is windows and not linux? i'd make a perl script, but you probably don't have a perl interpreter.

    if it's simple this might work in the cmd prompt.

    type *.txt >> newfile.txt
     
    Last edited: Feb 11, 2009
  3. OFI

    OFI New Member

    Joined:
    Apr 6, 2006
    Messages:
    52,607
    Likes Received:
    0
    Location:
    Wet Wales
    Yea sorry this is in Windows (XP)

    Trying that out now :)
     
  4. OFI

    OFI New Member

    Joined:
    Apr 6, 2006
    Messages:
    52,607
    Likes Received:
    0
    Location:
    Wet Wales
    Sweet that looks like it should work with a bit of tweaking.

    It doesn't add the extra file on a new line which is a shame, haven't checked the files yet but hopefully they end on a new line..

    For instance my files of

    File1:

    one line 1
    one line 2
    one line 3
    one line 4
    one line 5

    File 2:

    two line 1
    two line 2
    two line 3
    two line 4
    two line 5

    File 3:

    three line 1
    three line 2
    three line 3
    three line 4
    three line 5



    Became:

    one line 1
    one line 2
    one line 3
    one line 4
    one line 5three line 1
    three line 2
    three line 3
    three line 4
    three line 5two line 1
    two line 2
    two line 3
    two line 4
    two line 5


    Thanks for that, should be able to work something out tomorrow now :-D Two minutes for the answer too lol
     
  5. The Great Deceiver

    The Great Deceiver 21st Century Schizoid Man

    Joined:
    May 27, 2006
    Messages:
    59,204
    Likes Received:
    0
    Location:
    If you have excel you can import data into excel, each one into a column. If you mess around for a little while with:

    (click) Data -> Import external data -> Import data

    You would eventually get it
     
  6. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,443
    Likes Received:
    12
    to add new line to each file try

    for %a in (*.txt) do echo. >> %a

    you can all concatenate files with the dos copy command

    copy /b *.txt newfile.txt
     
  7. OFI

    OFI New Member

    Joined:
    Apr 6, 2006
    Messages:
    52,607
    Likes Received:
    0
    Location:
    Wet Wales
    :eek3:

    I won't even pretend to understand that but i'll give it a shot if the files are causing problems cheers :)
     
  8. retorq

    retorq What up bitch??

    Joined:
    Dec 14, 2006
    Messages:
    6,061
    Likes Received:
    0
    Location:
    Mohave Desert
    ummm ...

    copy file.a+file.b = file.c
     
  9. retorq

    retorq What up bitch??

    Joined:
    Dec 14, 2006
    Messages:
    6,061
    Likes Received:
    0
    Location:
    Mohave Desert
    /b is the binary switch I don't think he needs that with a std text file.
     
  10. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,443
    Likes Received:
    12
    It removes the last trailing ^M or it doesn't take it into account since it does it in binary
     
  11. OFI

    OFI New Member

    Joined:
    Apr 6, 2006
    Messages:
    52,607
    Likes Received:
    0
    Location:
    Wet Wales
    Did this today and managed to get all my files together :)

    Did have a small problem which was easily fixed. During the creation of the newfile it must have found itself and therefore added the contents twice. Just moved the newfile elsewhere :)

    Cheers
     

Share This Page