Re: Help "joining" two files delimited with pipe character ("|")

Discussion in 'Python' started by Ian Kelly, Dec 5, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Wed, Dec 5, 2012 at 10:57 AM, Daniel Doo <> wrote:
    > I am new to Python. Is there a method to “join” two pipe delimited files
    > using a unique key that appears in both files? I would like to implement
    > something similar to the Unix join command.


    If the files are small enough to fit in virtual memory, load one of
    the files into a dict where the key is the join field and the value is
    the full line. Then iterate over the other file one line at a time,
    checking to see if the join field is in the dict. If it is, output
    the joined line. Otherwise, skip it.
     
    Ian Kelly, Dec 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samantha
    Replies:
    7
    Views:
    141
    Samantha
    Mar 7, 2007
  2. PerlFAQ Server
    Replies:
    0
    Views:
    395
    PerlFAQ Server
    Jan 25, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    477
    PerlFAQ Server
    Apr 13, 2011
  4. Miki Tebeka
    Replies:
    0
    Views:
    165
    Miki Tebeka
    Dec 5, 2012
  5. Ian Kelly
    Replies:
    0
    Views:
    174
    Ian Kelly
    Dec 5, 2012
Loading...

Share This Page