Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34308
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'output': 0.04; 'subject:two': 0.07; 'command.': 0.09; 'delimited': 0.09; 'dict': 0.09; 'iterate': 0.09; 'subject:files': 0.09; 'subject:Help': 0.10; 'dec': 0.15; 'subject:joining': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'skip': 0.17; 'appears': 0.18; 'load': 0.19; 'otherwise,': 0.20; 'not,': 0.21; 'assumes': 0.22; 'pipe': 0.22; 'header:In-Reply-To:1': 0.25; 'fit': 0.26; 'am,': 0.27; 'checking': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'daniel': 0.30; 'lists': 0.31; 'implement': 0.32; 'file': 0.32; 'joined': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'similar': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'subject:" ': 0.36; 'method': 0.36; 'subject:with': 0.36; 'enough': 0.36; 'two': 0.37; 'virtual': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'time,': 0.62; 'charset:windows-1252': 0.65; 'dict.': 0.84; 'to:name:python': 0.84; 'unique.': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=AFv3cDQozD9Bu+GRYAW8PHVcpaS2dEuqgC2DYEFq2/E=; b=sPFbsIUyPj2S3+LVY8GRfP/N0pAqM+6ABjh6Ui//VUD4OJ98rVqZae8TjU/G/Orv9I JlrDGmYlBmepFqyPhwI4jhFDu0c2GeQfq9SsNOYtoe5g1kWIWNimkiq+Qw4Bpct8kILy g5DyWx4daNXDmczH21Irsfwmu5dG91j7DkRxS7PGZEvQABFXXUIsr4O3yyocV9X5Ht5e gBfuhdYtYPsVhF66UIbYbrJY19EiZHmab2je8Fuk99dQXFzZHrnembKIwt89mjGPBh9F 3Tps5jST+uU5O6mCFxb2mfMr+4e7I6pmlfixxA3lRunxEi2VNqwhSCw8wu+cZ2rZpkZw wt4w== |
| MIME-Version | 1.0 |
| In-Reply-To | <CALwzid=+vUEM1xRXAi2Oxus9D5v2B+5XAf6pMhyqCmJejm0oVw@mail.gmail.com> |
| References | <08080305078A3F47B751F7412214A051011B096BF3@MBX22.exg5.exghost.com> <CALwzid=+vUEM1xRXAi2Oxus9D5v2B+5XAf6pMhyqCmJejm0oVw@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 5 Dec 2012 11:22:22 -0700 |
| Subject | Re: Help "joining" two files delimited with pipe character ("|") |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.515.1354731774.29569.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1354731774 news.xs4all.nl 6942 [2001:888:2000:d::a6]:34379 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:34308 |
Show key headers only | View raw
On Wed, Dec 5, 2012 at 11:18 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote: > On Wed, Dec 5, 2012 at 10:57 AM, Daniel Doo <dd@topekacapitalmarkets.com> 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. Note that this assumes that the join fields are unique. If they're not, then you would need to store lists of lines rather than single lines in the dict.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Help "joining" two files delimited with pipe character ("|") Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-05 11:22 -0700
csiph-web