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


Groups > comp.lang.python > #42418

Re: Creating a dictionary from a .txt file

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'python,': 0.02; 'third- party': 0.04; 'output': 0.05; 'indexing': 0.07; 'subject:file': 0.07; 'string': 0.09; 'mining': 0.09; 'portions': 0.09; 'python': 0.11; 'assignment.': 0.16; 'fuzzy': 0.16; 'modules.': 0.16; 'received:74.208.4.195': 0.16; 'roy': 0.16; 'second-guess': 0.16; 'sorts': 0.16; 'subject:.txt': 0.16; 'tuple,': 0.16; 'two.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'input': 0.22; 'install': 0.23; 'header:User-Agent:1': 0.23; '31,': 0.24; 'subject: .': 0.24; "i've": 0.25; 'push': 0.26; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'correct': 0.29; 'matching': 0.30; 'said,': 0.30; 'gives': 0.31; '>>>>': 0.31; 'supplier': 0.31; 'interface': 0.32; 'up.': 0.33; 'subject:from': 0.34; 'could': 0.34; 'problem': 0.35; 'agree': 0.35; 'problem.': 0.35; 'case,': 0.35; 'done.': 0.35; 'but': 0.35; 'manufacturer': 0.36; 'should': 0.36; 'effort': 0.37; 'example,': 0.37; 'two': 0.37; 'project': 0.37; 'list.': 0.37; 'being': 0.38; 'sometimes': 0.38; 'thank': 0.38; 'to:addr:python- list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'dave': 0.60; 'life,': 0.60; 'march': 0.61; 'simple': 0.61; 'back': 0.62; 'times': 0.62; "you've": 0.63; 'real': 0.63; 'iron': 0.68; 'landscape': 0.68; 'received:74.208': 0.68; 'smith': 0.68; 'press': 0.70; 'car': 0.72; 'day': 0.76; 'article': 0.77; '"it': 0.84; '(ie': 0.84; 'homework': 0.84; 'kesha': 0.84; 'ordered.': 0.84; 'presumably': 0.84; 'angel': 0.91; 'motor': 0.91; '2013': 0.98
Date Sun, 31 Mar 2013 17:37:33 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: Creating a dictionary from a .txt file
References <d15c39bc-5d2a-42c9-a76b-23768b61c391@googlegroups.com> <mailman.4019.1364746832.2939.python-list@python.org> <d1a5fee7-2ce6-4446-8193-587e4c12a0a0@googlegroups.com> <mailman.4023.1364751102.2939.python-list@python.org> <roy-A43BBD.14414131032013@news.panix.com>
In-Reply-To <roy-A43BBD.14414131032013@news.panix.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:cHaZ7+ocTkTPbhc6R4LH1JixZJqZhE+ZaS48MsYjjAF aRF9kqC2pule3h+129Xh1X67OdSVmo5grvTcaB2qIyFr4y0te+ WCq5FplxUdl61xXEQ3Vq8sYwe7Y3qy8gyWbXqzwVHqdxH/GmzF pjFH5CwZKrmF13CdMChZR86iUrl5FgygHkwl3airpF5EfKzPts cj6VQVVXN7TzXr8XKH9YY+gy1rXjEigiBDp99FYCz5UgzTZHhq JMYWE3Tjy7rxHyt/3i8jBHF9ZVzWSS73IslXH3bay1X9Wfbult s2RJcBFjGFpFU9TCpaWfu35z31cKINrA2DrIM5i4DHE7i3nsQ= =
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.4032.1364765875.2939.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364765875 news.xs4all.nl 6889 [2001:888:2000:d::a6]:54533
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42418

Show key headers only | View raw


On 03/31/2013 02:41 PM, Roy Smith wrote:
> In article <mailman.4023.1364751102.2939.python-list@python.org>,
>   Dave Angel <davea@davea.name> wrote:
>
>> On 03/31/2013 12:52 PM, C.T. wrote:
>>> On Sunday, March 31, 2013 12:20:25 PM UTC-4, zipher wrote:
>>>>   <SNIP>
>>>>
>>>
>>> Thank you, Mark! My problem is the data isn't consistently ordered. I can
>>> use slicing and indexing to put the year into a tuple, but because a car
>>> manufacturer could have two names (ie, Aston Martin) or a car model could
>>> have two names(ie, Iron Duke), its harder to use slicing and indexing for
>>> those two.  I've added the following, but the output is still not what I
>>> need it to be.
>>
>> So the correct answer is "it cannot be done," and an explanation.
>>
>> Many times I've been given impossible conditions for a problem.  And
>> invariably the correct solution is to press [back] on the supplier of the
>> constraints.
>
> In real life, you often have to deal with crappy input data (and bogus
> project requirements).  Sometimes you just need to be creative.
>
> There's only a small set of car manufacturers.  A good start would be
> mining wikipedia's [[List of automobile manufacturers]].  Once you've
> got that list, you could try matching portions of the input against the
> list.
>
> Depending on how much effort you wanted to put into this, you could
> explore all sorts of fuzzy matching (ie "delorean" vs "delorean motor
> company"), but even a simple search is better than giving up.
>
> And, this is a good excuse to explore some of the interesting
> third-party modules.  For example, mwclient ("pip install mwclient")
> gives you a neat Python interface to wikipedia.  And there's a whole
> landscape of string matching packages to explore.
>
> We deal with this every day at Songza.  Are Kesha and Ke$ha the same
> artist?  Pushing back on the record labels to clean up their catalogs
> isn't going to get us very far.
>

I agree with everything you've said, although in your case, presumably 
the record labels are not your client/boss, so that's not who you push 
back against.  The client should know when the data is being fudged, and 
have a say in how it's to be done.

But this is a homework assignment.  I think the OP is learning Python, 
not how to second-guess a client.


-- 
DaveA

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