Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42379

Re: Creating a dictionary from a .txt file

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dreamingforward@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.055
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'element': 0.07; 'subject:file': 0.07; 'cc:addr:python-list': 0.11; 'appreciated!': 0.16; 'cc:name:python list': 0.16; 'subject:.txt': 0.16; 'tuple': 0.16; 'value.': 0.19; 'cc:addr:python.org': 0.22; 'subject: .': 0.24; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header :In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'subject:from': 0.34; 'received:google.com': 0.35; 'manufacturer': 0.36; 'should': 0.36; 'list': 0.37; 'how': 0.40; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'sample': 0.67; 'containing': 0.69; 'car': 0.72; 'd[2]': 0.84; 'washington': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=0FeAMOPUwFk7e3Fd+owCmvIfx17CrE62M/zIyfKehzg=; b=kqtGsaWSgpYeKqa/HYek8zRpVt7s22bHLj3NtpERUTTjyUr4qgMIFAT4ogyA8+g1XU UR1NUS54R/9NTy/7g1DQ0wFyyVeL/+THiNf8kxChOnp7PTaZBFBDkuYBYs4fDWrGzzE6 zmfX/8Lyl8vwq/M3CNhEQzjJwFLcHxLP2WCrbHTqnGZKFztm1cw2cbBr4mnF+oubZTUv lmiqDwBbtOqxsoTFjn23E9/lx9KOPVSNGXamTgBtXbyASwcohgvjIhpSrYa+mfVm7C0I aisO33XhieoDDCmUJ3/1eS/GVLExAlHITvZ2YHLwyFqdMBM7zkd97Zjt5qEpqRtUW9aU TEQA==
MIME-Version 1.0
X-Received by 10.180.77.66 with SMTP id q2mr6311450wiw.13.1364746825529; Sun, 31 Mar 2013 09:20:25 -0700 (PDT)
In-Reply-To <d15c39bc-5d2a-42c9-a76b-23768b61c391@googlegroups.com>
References <d15c39bc-5d2a-42c9-a76b-23768b61c391@googlegroups.com>
Date Sun, 31 Mar 2013 09:20:25 -0700
Subject Re: Creating a dictionary from a .txt file
From Mark Janssen <dreamingforward@gmail.com>
To "C.T." <swilks06@gmail.com>
Content-Type multipart/alternative; boundary=f46d04389405be809e04d93ae19b
Cc Python List <python-list@python.org>
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.4019.1364746832.2939.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364746832 news.xs4all.nl 6927 [2001:888:2000:d::a6]:47885
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42379

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

>
> Every line is now an element in list d. The question I have now is how can
> I make a dictionary out of the list d with the car manufacturer as the key
> and a tuple containing the year and the model should be the key's value.
> Here is a sample of what list d looks like:
>
> ['1899 Horsey Horseless', '1909 Ford Model T', '1911 Overland OctoAuto',
> '2003 Hummer H2', '2004 Chevy SSR']
>
> Any help would be appreciated!
>
>
As long as your data is consistently ordered, just use list indexing.  d[2]
is your key, and (d[1],d[3]) the key's value.

Mark
Tacoma, Washington

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 08:52 -0700
  Re: Creating a dictionary from a .txt file Chris Angelico <rosuav@gmail.com> - 2013-04-01 03:06 +1100
    Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 10:19 -0700
      Re: Creating a dictionary from a .txt file Chris Angelico <rosuav@gmail.com> - 2013-04-01 04:22 +1100
    Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 10:19 -0700
  Re: Creating a dictionary from a .txt file Mark Janssen <dreamingforward@gmail.com> - 2013-03-31 09:20 -0700
    Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 09:52 -0700
      Re: Creating a dictionary from a .txt file Dave Angel <davea@davea.name> - 2013-03-31 13:31 -0400
        Re: Creating a dictionary from a .txt file Roy Smith <roy@panix.com> - 2013-03-31 14:41 -0400
          Re: Creating a dictionary from a .txt file Dave Angel <davea@davea.name> - 2013-03-31 17:37 -0400
          Re: Creating a dictionary from a .txt file Neil Cerutti <neilc@norwich.edu> - 2013-04-01 11:41 +0000
            Re: Creating a dictionary from a .txt file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-01 23:53 +0000
              Re: Creating a dictionary from a .txt file Walter Hurry <walterhurry@lavabit.com> - 2013-04-02 00:28 +0000
              Re: Creating a dictionary from a .txt file Neil Cerutti <neilc@norwich.edu> - 2013-04-03 12:55 +0000
    Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 09:52 -0700
  Re: Creating a dictionary from a .txt file Roy Smith <roy@panix.com> - 2013-03-31 12:38 -0400
    Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-03-31 10:28 -0700
  Re: Creating a dictionary from a .txt file Terry Jan Reedy <tjreedy@udel.edu> - 2013-03-31 15:04 -0400
  Re: Creating a dictionary from a .txt file "C.T." <swilks06@gmail.com> - 2013-04-01 16:53 -0700
    Re: Creating a dictionary from a .txt file Dave Angel <davea@davea.name> - 2013-04-01 20:12 -0400

csiph-web