ok, thanks On Fri, Aug 24, 2012 at 1:00 AM, Dave Angel <d...@davea.name> wrote:
> On 08/23/2012 02:33 PM, Norman Khine wrote: > > Hello, > > I have this code (http://pastie.org/4575790) which pulls data from a > list > > and then modifies some of the values such as the 'yield' entry, which has > > entries like: > > > > 21 > > 15 > > ≤ 1000 > > ≤ 20 > > 2.2 - 30 > > > > so that they are cleaned up. > > > > # -*- coding: UTF-8 -*- > > # Norman Khine <nor...@zmgc.net> > > import operator, json > > from BeautifulSoup import BeautifulSoup > > > > combos={0: 'id', > > 2: 'country', > > 3: 'type', > > 5: 'lat', > > 6: 'lon', > > 12: 'name' } > > > > TABLE_CONTENT = [['958','<a id="958F" href="javascript:c_row(\'958\')" > > <snip> > > event_list = [] > > for event in TABLE_CONTENT: > > event_dict = {} > > for index, item in enumerate(event): > > if index == 8: > > if item == ' ': > > event_dict['depth'] = '0' > > else: > > event_dict['depth'] = item > > if index == 9: > > try: > > <snip> > > can the code be improved further? > > No idea. You mistakenly posted in html, so most of us cannot read the > indentation. This is a text forum. (Yah, I know I could read the > pastie link, but I try to stay within the list) > > > > > > also, the content has 2,153 items, what will be the correct way to have > > this in a separate file and import this within this file to work on it? > > I assume you mean TABLE_CONTENT ? > > Just move the whole assignment to a new module, perhaps content.py, > then import it as > > from content import TABLE_CONTENT > > > > > > -- > > DaveA > > -- %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor