Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9467
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <EEllerbee@BBandT.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '2.7': 0.04; 'classes.': 0.05; 'mrab': 0.05; 'prints': 0.07; 'skip:[ 40': 0.07; 'python': 0.08; '"["': 0.09; "(i'm": 0.09; 'beating': 0.09; 'collections': 0.09; 'dict': 0.09; 'python.org?': 0.09; 'question:': 0.09; 'subject:don': 0.09; 'throw': 0.09; 'message-----': 0.12; 'book!': 0.16; 'codes,': 0.16; 'except:': 0.16; 'expression,': 0.16; 'pity': 0.16; 'pulls': 0.16; 'router.': 0.16; 'skip:# 60': 0.16; 'edward': 0.16; 'great.': 0.16; 'wednesday,': 0.16; 'this:': 0.16; '>>>': 0.16; 'subject:list': 0.16; 'file)': 0.19; 'insert': 0.19; 'previously': 0.19; 'seems': 0.20; "haven't": 0.21; 'figure': 0.21; 'variable': 0.21; 'seconds': 0.21; 'subject:not': 0.21; '(this': 0.22; 'file,': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'stuff': 0.22; 'trying': 0.23; 'builds': 0.23; 'code': 0.24; '(or': 0.25; 'specified': 0.25; 'string': 0.26; '(in': 0.26; 'tried': 0.27; "i'm": 0.27; 'url:mailman': 0.27; 'pass': 0.28; 'somebody': 0.28; 'putting': 0.28; 'correct': 0.29; 'import': 0.29; 'script': 0.29; 'lists': 0.29; 'example': 0.30; 'subject:': 0.30; 'module': 0.30; 'list1': 0.30; 'thanks': 0.31; 'least': 0.31; 'seem': 0.31; 'url:listinfo': 0.32; 'print': 0.32; 'list': 0.32; 'list.': 0.33; "i've": 0.33; 'to:addr:python-list': 0.34; 'calling': 0.34; 'sent:': 0.34; 'there': 0.34; 'e.g.': 0.34; 'couple': 0.34; 'like:': 0.35; 'try:': 0.35; 'thank': 0.35; 'from:': 0.36; 'regular': 0.36; 'charset:us-ascii': 0.36; 'file': 0.36; 'data.': 0.36; 'url:python': 0.37; 'digit': 0.37; 'but': 0.37; 'could': 0.37; 'using': 0.37; 'url:org': 0.38; 'subject:: ': 0.38; 'something': 0.38; 'put': 0.38; 'common': 0.39; 'processing': 0.39; 'data': 0.39; 'i.e.': 0.39; 'spent': 0.39; 'list,': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.39; 'might': 0.39; 'determine': 0.40; 'format': 0.40; "i'd": 0.40; 'skip:r 20': 0.40; 'phone': 0.63; 'skip:5 10': 0.63; 'july': 0.64; 'taking': 0.65; 'gathering': 0.67; 'skip:l 50': 0.67; 'experts': 0.69; 'voice': 0.69; 'dealing': 0.69; 'today': 0.71; '3-4': 0.71; 'concatenate': 0.84; 'data?': 0.84; 'drops': 0.84; 'ugly,': 0.84; 'format)': 0.91; 'items,': 0.91; 'texas,': 0.91; '150': 0.93; 'subject:good': 0.93; 'subject:know': 0.93 |
| X-IronPort-AV | E=Sophos;i="4.65,529,1304308800"; d="scan'208";a="42879760" |
| X-Server-Uuid | 7C9F3A3D-0A58-4F63-8FA5-251C0509CB4B |
| X-MimeOLE | Produced By Microsoft Exchange V6.5 |
| Content-class | urn:content-classes:message |
| MIME-Version | 1.0 |
| Subject | RE: I don't know list, I not good at list. |
| Date | Thu, 14 Jul 2011 09:05:05 -0400 |
| In-Reply-To | <4E1E151A.4070006@mrabarnett.plus.com> |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| Thread-Topic | I don't know list, I not good at list. |
| Thread-Index | AcxBq15/KDy7Z9ksTNO4+ArUc993mgAeSNgw |
| References | <77AE044B1BF3944FAE2435F395F11B4B018599C6@clt-exmb02.bbtnet.com> <4E1E151A.4070006@mrabarnett.plus.com> |
| From | "Ellerbee, Edward" <EEllerbee@BBandT.com> |
| To | python-list@python.org |
| X-OriginalArrivalTime | 14 Jul 2011 13:05:06.0203 (UTC) FILETIME=[A6D466B0:01CC4226] |
| X-CFilter-Loop | Reflected |
| X-WSS-ID | 620034941ZO1886546-41-01 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.1022.1310648750.1164.python-list@python.org> (permalink) |
| Lines | 119 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1310648750 news.xs4all.nl 23878 [2001:888:2000:d::a6]:33225 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:9467 |
Show key headers only | View raw
Thank you all for the advice, let me spin this in a different way.
I've built a program that goes to the NANPA website, scrapes area
code/exchange (npa/nxx) digits for a specified area - be it carolina,
alabama, texas, etc - drops it into a file, then massages the data and
prints out the correct format to insert into a voice router. The code is
ugly, but it works great.
The thing I haven't been able to get my script to do is to reduce the
amount of dial-peers. Hence the need to reduce the numbers to the least
common denominator, and put it in the xxxxx[xx] format.If we had a set
number of digits, we could build a dictionary(unless it's possible to do
that dynamically).
So, a couple assertions:
1. the data will always be 6 digit numbers (in a string format)
2. the data is in a txt file after being put there from my script
3. the data will never be the same (I'm going to use this for site
conversions/new site builds
e.g. today I might be dealing with 252-, 919- and 704- area
codes, tomorrow might be 304- and 754-
4. I wanted a script to reduce the time taking to build the dial-peers
manually. I'd previously spent 3-4 hours
on gathering and processing data. The script I have so far pulls data
and massages in about 6 seconds
5. I'm using python 2.7 - it seems like it had more module availability
than 3
And a couple question:
1. Would lists be the best way to handle this data? Would it be better
to process this data from a file?
2. Is there a way to determine the common (first-5 digits) denominator
among a list (or file) of data?
3. and... Could those common numbers be inserted in a dict for
processing?
Sorry for the book!
thanks
Edward Ellerbee
-----Original Message-----
From: python-list-bounces+eellerbee=bbandt.com@python.org
[mailto:python-list-bounces+eellerbee=bbandt.com@python.org] On Behalf
Of MRAB
Sent: Wednesday, July 13, 2011 5:59 PM
To: python-list@python.org
Subject: Re: I don't know list, I not good at list.
> I've been beating my head against the desk trying to figure out a >
method to accomplish this:
>
> Take a list (this example is 5 items, It could be 150 or more - i.e.
> it's variable length depending on the city/local calling zones) > >
The first 6 digits of phone numbers(NPA/NXX) in a local calling area.
> I want to concatenate the last digit for insertion into a call >
routing pattern.
>
> I tried this and failed miserably:
>
> list1=['252205','252246','252206','252247','252248']
> for item in list1:
> try:
> item1=list1[0]
> item2=list1[1]
> if item1[0:5] == item2[0:5]:
> print item1[0:5] + '[' + item1[5:6] +
item2[5:6] + ']'
> list1.pop(0)
> else:
> print item1
> list1.pop(0)
> except:
> try:
> print item1
> list1.pop(0)
> except:
> pass
>
> #-----------------------------------------------------------------
> My intent is to have the end data come out (from the example list >
above) in the format of > 25220[56] > 25224[678] > > I tried putting
together a variable inserted into a regular > expression, and it
doesn't seem to like:
> Item1=list1[0]
> Itemreg = re.compile(Item1[0:5])
> For stuff in itemreg.list1:
> #do something
>
> Can somebody throw me a bone, code example or module to read on >
python.org? I'm a n00b, so I'm still trying to understand functions >
and classes.
>
> I thought the experts on this list might take pity on my pathetic >
code skillz!
>
defaultdict comes in handy:
>>> list1 = ['252205','252246','252206','252247','252248']
>>> from collections import defaultdict >>> d = defaultdict(set) >>>
for item in list1:
d[item[ : 5]].add(item[5 : ])
>>> d
defaultdict(<class 'set'>, {'25224': {'8', '7', '6'}, '25220': {'5',
'6'}}) >>> for k, v in d.items():
print(k + "[" + "".join(v) + "]")
25224[876]
25220[56]
--
http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: I don't know list, I not good at list. "Ellerbee, Edward" <EEllerbee@BBandT.com> - 2011-07-14 09:05 -0400
csiph-web