#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    22
    Rep Power
    0

    Merging contents of many files


    Hi all,

    I want to merge contents of many files as follows (following examples are with 2 files, but actually I have thousands of such files):

    If my first file (file1.txt) contains-

    >1st
    the_sky_is
    >2nd
    the_color_of_
    the_field_

    and the second file (file2.txt) contains-

    >1st
    _blue
    >2nd
    is_green

    then the concatenated output file (out.txt) should contain-

    >1st
    the_sky_is_blue
    >2nd
    the_color_of_
    the_field_is_green

    note that the order of the file (first file1.txt then file2.txt) should not change..

    plz help..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    76
    Rep Power
    2
    I'm confused, when you say >1st and >2nd are you indicating line numbers or are you suggesting the actual, verbatim text of the file?
    What does this do? It sounds to me like there might be a much simpler way to do what you're really trying to do that might not have so much I/O involved.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    22
    Rep Power
    0
    Originally Posted by Mr909
    I'm confused, when you say >1st and >2nd are you indicating line numbers or are you suggesting the actual, verbatim text of the file?
    What does this do? It sounds to me like there might be a much simpler way to do what you're really trying to do that might not have so much I/O involved.
    I could write anything instead of "1st" and "2nd" like "anything1" "anything2", they are just header descriptions,but
    these descriptions are same in all the files, that means, if in file1.txt, the header descriptios are "anything1" and "anything2", for file2.txt
    the header descriptios are also "anything1" and "anything2".

    These header descriptions are used to match the content below it,, thus in output concatenated file, header description "1st" (or "anything1") have merged content of file1 and file2 that are also under the same header in those files(see sample ouput) ...
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    Install unix (cygwin/x11 perhaps) then use the lam or paste commands.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo