Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Help "joining" two files delimited with pipe character ("|")

Reply
Thread Tools

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

 
 
Ian Kelly
Guest
Posts: n/a
 
      12-05-2012
On Wed, Dec 5, 2012 at 10:57 AM, Daniel Doo <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Help "joining" two files delimited with pipe character ("|") Ian Kelly Python 0 12-05-2012 06:22 PM
Re: Help "joining" two files delimited with pipe character ("|") Miki Tebeka Python 0 12-05-2012 06:17 PM
FAQ 4.31 How can I split a [character] delimited string except when inside [character]? PerlFAQ Server Perl Misc 0 04-13-2011 10:00 PM
FAQ 4.31 How can I split a [character] delimited string except when inside [character]? PerlFAQ Server Perl Misc 0 01-25-2011 05:00 AM



Advertisments