Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
the
Jul 18, 2004

by Cowcaster

sund posted:

Yeah, it'll be caching writes for you.

Having to iterate like you do looks kinda weird to me. What's your input data look like?

This, except it was originally from an excel file. What do you mean how I'm iterating is weird?

edit: this is the ~500 item file that I have to check against another ~10000 file which basically contains the same stuff

the fucked around with this message at 17:42 on Jul 11, 2014

Adbot
ADBOT LOVES YOU

FoiledAgain
May 6, 2007

the posted:

edit: Or maybe It writes in chunks? Or something... because it just jumped to 4.1kb in size from 0 bytes while it's still running. Weird stuff, man. Weird stuff.

You can usually force the write to happen by using file.flush(), which in your case would be something like:

Python code:
with open('dupes.csv', 'wt') as dupes, open('unique.csv', 'wt') as uniques:
    #other stuff cut out
    if (fuzz.ratio(cN[i],hN[j]) > 90): #Check Name for match
        if (fuzz.ratio(cC[i],hC[j]) > 85): #Check city for match
            dupewriter.writerow(c[i])
            dupes.flush()
        else:
            uniquewriter.writerow(c[i])
            uniques.flush()

Sirocco
Jan 27, 2009

HEY DIARY! HA HA HA!
I'm struggling a bit with tkinter's text widget here. I want to be able to have the text inserted for display one character at a time typewriter-style. I figured this code would do it:

code:
def show_text(text):

    info_box.config(state = NORMAL)

    for char in list(text):
        info_box.insert(END, char)
        sleep(0.1)

    info_box.config(state = DISABLED)
But it just outputs everything simultaneously instead. I learned you could use sys.stdout.flush() for the print function, but I'm not finding anything for the text widget. I assume there's a way to do this?

edit: well, I feel foolish, found the right keywords Google needed to get me the answer. Here's the link if anyone's interested:

http://stackoverflow.com/questions/15362372/display-realtime-output-of-a-subprocess-in-a-tkinter-widget

Sirocco fucked around with this message at 17:20 on May 6, 2014

Super 3
Dec 31, 2007

Sometimes the powers you get are shit.
I'm sure that a big part of the csv sorting was the experience and challenge of writing it in Python but Excel has built in functionality for checking for dupes and while it doesn't have regex it can be extended to do matching I've done this a few times. Last time this came up I remember looking at Python first and realized that it was faster to just use Excel.

the
Jul 18, 2004

by Cowcaster
For my next trick, I'm going (learn how) to scrub the phone results off google searches for all of those in the csv file.

So for something like https://www.google.com/#q=wake+med+raleigh+nc

I'd want to scrub that phone # that pops up.

I'm sure this is rather easy on the end of python stuff, but it's new to me!

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

the posted:

For my next trick, I'm going (learn how) to scrub the phone results off google searches for all of those in the csv file.

So for something like https://www.google.com/#q=wake+med+raleigh+nc

I'd want to scrub that phone # that pops up.

I'm sure this is rather easy on the end of python stuff, but it's new to me!

I think "scrape" is the word you are looking for. Also that might be a lot easier using the Google Maps API, rather than trying to scrape the Google Search results.

salisbury shake
Dec 27, 2011
Make friends with requests and beautifulsoup4. A source like this might be easier to parse than a desktop Google search: turn off javascript in your browser and try googling your term again, you won't get the nicely formatted information on the side.

Python code:
In [26]: import requests

In [27]: import bs4

In [29]: url = "http://www.yellowpages.com/raleigh-nc/wake-med-hospital"

In [30]: response = requests.get(url)

In [31]: bs_content = bs4.BeautifulSoup(response.content)

In [32]: bs_content.find('span', 'business-phone')
Out[32]: 
<span class="business-phone phone">
(919) 596-3560
</span>

In [35]: full_listings = bs_content.find_all('div', 'business-container-inner')

In [36]: len(full_listings)
Out[36]: 22

In [37]: for listing in full_listings:
   ....:     name = listing.find('a', 'url').text.strip()
   ....:     number = listing.find('span', 'business-phone').text.strip()
   ....:     print(name, ': ', number)
   ....:     
Wake Med Health & Hospital :  (919) 596-3560
WakeMed :  (919) 878-7650
Wake Med Home Health :  (919) 350-7990
Center Wake Med Health Care :  (919) 847-3168
WakeMed Faculty Physicians Ent-Head & Neck Surgery :  (919) 350-1630
WakeMed Doctor Choice :  (919) 350-8900
WakeMed :  (919) 233-2301
WakeMed :  (919) 269-4400
Women's Center of Wake County :  (919) 829-3711
FastMed Urgent Care in Wake Forest :  (919) 562-3155
Med Mart Urgent Care :  (919) 772-9214
Wake Veterinary Hospital Inc :  (919) 266-9852
Wake Forest Animal Hospital :  (919) 867-5804
North Wake Animal Hospital :  (919) 556-1121
East Wake Animal Hospital :  (919) 375-4180
Eastern Wake Hospital :  (919) 269-4352
Western Wake Medical Ctr :  (919) 350-2300
Wake Radiology :  (919) 232-4700
Wake Interfaith Hospitality Network :  (919) 832-6024
Best Western Raleigh North-Downtown :  (877) 722-3422
Holiday Inn RALEIGH NORTH - CAPITAL BLVD :  (888) 978-3956
Carymed Primary Care :  (919) 238-6132

salisbury shake fucked around with this message at 00:22 on May 8, 2014

namaste friends
Sep 18, 2004

by Smythe
What's the coolest thing any of you have done with a decorator?

I'm thinking about encapsulating my RESTful API calls with a decorator that opens and closes sessions, but then that kind of defeats the purpose of session management.

the
Jul 18, 2004

by Cowcaster
Regarding using the Google Search API, is this something that would set me up to do that?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

the posted:

Regarding using the Google Search API, is this something that would set me up to do that?

Nope, that's for searching your own sets of data on Google App Engine. This looks like it might be more what you're after: http://py-googlemaps.sourceforge.net/#local-search

the
Jul 18, 2004

by Cowcaster

fletcher posted:

Nope, that's for searching your own sets of data on Google App Engine. This looks like it might be more what you're after: http://py-googlemaps.sourceforge.net/#local-search

Thanks, after looking around I think I might go with using the Yelp API, unless you think the other one is better.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

the posted:

Thanks, after looking around I think I might go with using the Yelp API, unless you think the other one is better.

That one looks viable as well. Make sure you are aware of the API request limits, not sure about the size of your dataset and whether or not you'd run into these.

Yelp:

quote:

How many API calls do I get?
We start you off with 10,000 calls per day. If you need additional access, please contact api@yelp.com with links or screenshots of your app or website. We'll review your request and get you up to speed as quickly as we can!

the
Jul 18, 2004

by Cowcaster
That was going to be my follow up question, sort of. Does it matter if I'm doing this on behalf of a for-profit company?

edit:

quote:

You may not:

Cache, store, analyze or otherwise use Yelp content except for real-time consumer-driven use.

So that rules that out, right?

the fucked around with this message at 18:09 on May 8, 2014

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

the posted:

That was going to be my follow up question, sort of. Does it matter if I'm doing this on behalf of a for-profit company?

You'll want to review their API Terms of Use. Also just a heads up, the Yelp API does not return results for a business that has not been reviewed yet.

the
Jul 18, 2004

by Cowcaster
Why is this happening?

code:
sudo easy_install googlemaps

Best match: googlemaps 1.0.2
Processing googlemaps-1.0.2-py2.7.egg
googlemaps 1.0.2 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/googlemaps-1.0.2-py2.7.egg
Processing dependencies for googlemaps
Finished processing dependencies for googlemaps
Yet in Canopy:

code:
import googlemaps
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-80859df338b6> in <module>()
----> 1 import googlemaps

ImportError: No module named googlemaps 
edit: ended up running "pip install googlemaps" which worked, I hope it's the same thing.

the fucked around with this message at 18:43 on May 8, 2014

the
Jul 18, 2004

by Cowcaster
I'm using the Yelp API, and it looks like it's returning things as a unicode dict? Gross. I'm trying to figure out how I can convert the entire thing to ascii, but also access specific parts of the list (I just need the phone #).

Here's an example output of a Yelp query:

quote:

{u'businesses': [{u'categories': [[u'Doctors', u'physicians'],
[u'Hospitals', u'hospitals'],
[u'Medical Centers', u'medcenters']],
u'display_phone': u'+1-919-784-3100',
u'id': u'rex-hospital-raleigh',
u'image_url': u'http://s3-media3.ak.yelpcdn.com/bphoto/kKM4cL_k03EGMvYZRc6DmA/ms.jpg',
u'is_claimed': False,
u'is_closed': False,
u'location': {u'address': [u'4420 Lake Boone Trl'],
u'city': u'Raleigh',
u'country_code': u'US',
u'display_address': [u'4420 Lake Boone Trl', u'Raleigh, NC 27607'],
u'postal_code': u'27607',
u'state_code': u'NC'},
u'mobile_url': u'http://m.yelp.com/biz/rex-hospital-raleigh',
u'name': u'Rex Hospital',
u'phone': u'9197843100',
u'rating': 4.0,
u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
u'review_count': 18,
u'snippet_image_url': u'http://s3-media4.ak.yelpcdn.com/photo/lbsSXcUSo0OVoFQqWs1SDg/ms.jpg',
u'snippet_text': u'My elderly Dad was sent by EMS to Rex at the urging of his primary physician. Turned into a week stay dealing with a UTI and a blood infection.\nDad, as...',
u'url': u'http://www.yelp.com/biz/rex-hospital-raleigh'}]
u'region': {u'center': {u'latitude': 35.8173359, u'longitude': -78.7036654},
u'span': {u'latitude_delta': 0.0, u'longitude_delta': 0.0}},
u'total': 1}

To be honest I don't even really need to convert it to ascii, I just have to be able to access that u'phone' portion, but I can't figure out how to reference it.

edit: :ughh: So guess what? It turns out that is literally a list within a dict within a list within a dict.

Trying to drill into those results, once I finally accessed the first line:

Python code:
test = results(unicode('businesses')
Got me:

quote:

[{u'categories': [[u'Doctors', u'physicians'],
[u'Hospitals', u'hospitals'],
[u'Medical Centers', u'medcenters']],
u'display_phone': u'+1-919-784-3100',
u'id': u'rex-hospital-raleigh',
u'image_url': u'http://s3-media3.ak.yelpcdn.com/bphoto/kKM4cL_k03EGMvYZRc6DmA/ms.jpg',
u'is_claimed': False,
u'is_closed': False,
u'location': {u'address': [u'4420 Lake Boone Trl'],
u'city': u'Raleigh',
u'country_code': u'US',
u'display_address': [u'4420 Lake Boone Trl', u'Raleigh, NC 27607'],
u'postal_code': u'27607',
u'state_code': u'NC'},
u'mobile_url': u'http://m.yelp.com/biz/rex-hospital-raleigh',
u'name': u'Rex Hospital',
u'phone': u'9197843100',
u'rating': 4.0,
u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
u'review_count': 18,
u'snippet_image_url': u'http://s3-media4.ak.yelpcdn.com/photo/lbsSXcUSo0OVoFQqWs1SDg/ms.jpg',
u'snippet_text': u'My elderly Dad was sent by EMS to Rex at the urging of his primary physician. Turned into a week stay dealing with a UTI and a blood infection.\nDad, as...',
u'url': u'http://www.yelp.com/biz/rex-hospital-raleigh'}]

Which is a list. Great, I thought, let me try to access the first part of that list:

Python code:
test[0]
Gives me

quote:

{u'categories': [[u'Doctors', u'physicians'],
[u'Hospitals', u'hospitals'],
[u'Medical Centers', u'medcenters']],
u'display_phone': u'+1-919-784-3100',
u'id': u'rex-hospital-raleigh',
u'image_url': u'http://s3-media3.ak.yelpcdn.com/bphoto/kKM4cL_k03EGMvYZRc6DmA/ms.jpg',
u'is_claimed': False,
u'is_closed': False,
u'location': {u'address': [u'4420 Lake Boone Trl'],
u'city': u'Raleigh',
u'country_code': u'US',
u'display_address': [u'4420 Lake Boone Trl', u'Raleigh, NC 27607'],
u'postal_code': u'27607',
u'state_code': u'NC'},
u'mobile_url': u'http://m.yelp.com/biz/rex-hospital-raleigh',
u'name': u'Rex Hospital',
u'phone': u'9197843100',
u'rating': 4.0,
u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
u'review_count': 18,
u'snippet_image_url': u'http://s3-media4.ak.yelpcdn.com/photo/lbsSXcUSo0OVoFQqWs1SDg/ms.jpg',
u'snippet_text': u'My elderly Dad was sent by EMS to Rex at the urging of his primary physician. Turned into a week stay dealing with a UTI and a blood infection.\nDad, as...',
u'url': u'http://www.yelp.com/biz/rex-hospital-raleigh'}

Which is a dict :negative:

And then finally

Python code:
test2[unicode('phone')]
Gives me

code:
u'9197843100'
Sheesh.

the fucked around with this message at 21:04 on May 8, 2014

OnceIWasAnOstrich
Jul 22, 2006

I don't really understand your problem. I seem to be able to access a key defined as a unicode string in a dict d just fine either with d['phone'] or d[u'phone']. Including your dict after I remove the several syntax errors that somehow crept in. Is this a python3 thing?

the
Jul 18, 2004

by Cowcaster
I don't know, if that's an easier way then great, because what I did just up there ^^ was really long-winded. I'm learning this, so forgive my moronic buffoonery.

When I try what you just did, this happens:

Python code:
results['phone']
code:
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-64-33968f9d9b1b> in <module>()
----> 1 results['phone']

KeyError: 'phone' 

OnceIWasAnOstrich
Jul 22, 2006

There was some weird structure in that dict. Check to make sure it looks like you think it does. Take a look at the list of keys.

Python code:
print results.keys()
edit: Missed your edit. I have no idea why it works differently on my machine on both 2 and 3 if the dicts are the same. What is probably happening though is that they are giving you a nested dictionary like a lot of APIs and the 'phone' key is in a sub-dictionary, so you'll need to do something like results['businesses']['phone']

OnceIWasAnOstrich fucked around with this message at 21:20 on May 8, 2014

the
Jul 18, 2004

by Cowcaster
The keys listed are: [u'region', u'total', u'businesses']

edit: You were right, this ended up working:

results['businesses'][0]['phone']

the fucked around with this message at 21:21 on May 8, 2014

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

the posted:

Why is this happening?

code:
sudo easy_install googlemaps
edit: ended up running "pip install googlemaps" which worked, I hope it's the same thing.

Yeah always use 'pip install' over easy_install

the
Jul 18, 2004

by Cowcaster
I'm going to throw in the towel on this attempt. For a few reasons:

-It looks like the Google Maps API won't let me find phone numbers, it's only designed really for geolocations. And even then, the python one from sourceforge uses the deprecated version.

-Yelp let's me find phone numbers, but it's notoriously unreliable. I was putting in known locations and it wouldn't give me them as the first result. And if a location wasn't entered into Yelp (as many on my list are) then it wouldn't work.

So, looks like I'll have to just search all of these manually. Poo.

No Safe Word
Feb 26, 2005

the posted:

-It looks like the Google Maps API won't let me find phone numbers, it's only designed really for geolocations. And even then, the python one from sourceforge uses the deprecated version.
Google Places API does

the
Jul 18, 2004

by Cowcaster

https://www.youtube.com/watch?v=UPw-3e_pzqU

BigRedDot
Mar 6, 2008

the posted:

I'm using the Yelp API, and it looks like it's returning things as a unicode dict? Gross.
That's because the underlying standard library json module does that. I'm not sure there was any better choice.

Dren
Jan 5, 2001

Pillbug

Cultural Imperial posted:

What's the coolest thing any of you have done with a decorator?

I'm thinking about encapsulating my RESTful API calls with a decorator that opens and closes sessions, but then that kind of defeats the purpose of session management.

The best use of decorators is stuff like what the web frameworks (like flask) do where they let you put @app.route('/poop') in order to have your function be called to serve that url. The @coroutine decorator where it calls .next() on the generator function is pretty good too.

Crosscontaminant
Jan 18, 2007

OnceIWasAnOstrich posted:

I don't really understand your problem. I seem to be able to access a key defined as a unicode string in a dict d just fine either with d['phone'] or d[u'phone']. Including your dict after I remove the several syntax errors that somehow crept in. Is this a python3 thing?
There are two kinds of thing involved here: sequences of bytes (which Python 2 calls str and Python 3 calls bytes) and strings of Unicode codepoints (which Python 2 calls unicode and Python 3 calls str) - some people will use the word "bytestring" to describe the former, and those people should be punched.

Python 2 will silently convert between the two without telling you using a default encoding which is defined in sys somewhere, so d['phone'] (using a str) and d[u'phone'] (using a unicode) will return whichever of those two keys actually happens to exist (and throw some flavour of UnicodeError under mysterious circumstances if you don't know how autopromotion works).

Python 3 doesn't do autopromotion from bytes to unicode because that's completely mental so if the dictionary has b'phone' and you ask for 'phone' you'll get a KeyError (and vice versa).

the
Jul 18, 2004

by Cowcaster
x-post from the linux thread, I'm trying to get the lxml.html module installed to use in Canopy with 2.7

I've run pip install lxml, but the installation fails.

I've also run

apt-get install libxml2-dev
apt-get install libxslt1-dev

which is what has been suggested in google results, and those are installed, yet it still fails.

Specific error is

quote:

/home/gronke/Enthought/Canopy_64bit/User/build/lxml/src/lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

#include "libxml/xmlversion.h"

^

compilation terminated.

error: command 'gcc' failed with exit status 1

Any help would be appreciated, thanks!

Vicar
Oct 20, 2007

Try apt-get install zlib1g-dev?

the
Jul 18, 2004

by Cowcaster

Vicar posted:

Try apt-get install zlib1g-dev?

Did that. Install of lxml still failed with the same error.

ohgodwhat
Aug 6, 2005

There's a goon at Continuum right? If you're the one who added a streamhandler to the root logger in numba 0.11... :stare:

For context, I have plenty of debug level logging statements littered through my code, and they were fine as they were - being logged to a file, until I called any function that had been JIT'd with numba. At that point, all the debug messages would henceforth be printed out to stdout as well.

ohgodwhat fucked around with this message at 00:33 on May 10, 2014

the
Jul 18, 2004

by Cowcaster
I'm trying to write a simple script to scrape the url links from cells on a webpage. I thought I had it figured out, but for some reason it's not working:

Python code:
import requests
import lxml.html
import cssselect
 
req = requests.get('http://tdcj.state.tx.us/unit_directory/')
root = lxml.html.fromstring(req.text)
 
tables = root.cssselect('table')
table = tables[0]
 
rows = table.cssselect('tr')
rows = rows[1:]
 
for row in rows:
    cells = row.cssselect('td')
    print cells[0].text_content()
    print cells[0].get('href')
    raw_input()
Prints out:

code:
Allred
None
Which is the first cell, and not the link, which is contained in the <td> element so I'm not sure why it's not seeing it. Any ideas?

edit: I can use

Python code:
.xpath('//a/href')
to find *every* link in the entire doc, but I'm trying to find only the one listed in that cell.

the fucked around with this message at 04:42 on May 10, 2014

Met48
Mar 15, 2009

the posted:

the link, which is contained in the <td> element

When you use cells[0].get('href') you're getting the (empty) href attribute of the td. You have to find the a element first (ex. cells[0].cssselect('a').get('href')).

the
Jul 18, 2004

by Cowcaster

Met48 posted:

When you use cells[0].get('href') you're getting the (empty) href attribute of the td. You have to find the a element first (ex. cells[0].cssselect('a').get('href')).

Ah, that's what I was missing. Thanks a million.

BannedNewbie
Apr 22, 2003

HOW ARE YOU? -> YOSHI?
FINE, THANK YOU. -> YOSHI.

ohgodwhat posted:

There's a goon at Continuum right? If you're the one who added a streamhandler to the root logger in numba 0.11... :stare:

For context, I have plenty of debug level logging statements littered through my code, and they were fine as they were - being logged to a file, until I called any function that had been JIT'd with numba. At that point, all the debug messages would henceforth be printed out to stdout as well.

I think that's a bug that will go away if you update to a newer numba. That was my experience anyway.

BigRedDot
Mar 6, 2008

ohgodwhat posted:

There's a goon at Continuum right? If you're the one who added a streamhandler to the root logger in numba 0.11... :stare:

For context, I have plenty of debug level logging statements littered through my code, and they were fine as they were - being logged to a file, until I called any function that had been JIT'd with numba. At that point, all the debug messages would henceforth be printed out to stdout as well.

Can you check to see if it still does that in newer versions? I did not do that but I will pass it along if it's still a problem.

ohgodwhat
Aug 6, 2005

Oh, no, it is fixed now. But I'm stuck on numba 0.11.1 for the time being. Do you know if there's any preferred way of working around it?

What I'm doing now is creating an autojited function immediately, calling it, and then resetting logging.root.handlers to an empty list (there might be a removeHandlers function which I should be calling instead...).

the
Jul 18, 2004

by Cowcaster
Lets say I have a string that's like

code:
115 Berry Lane, Plano, TX 24134
And I want to separate it into four strings of street, city, state, and zip.

The current way I'm doing it is:

-Search for first comma
-Slice off the first part and make that the street
-Set the rest equal to a temp string
-Search for next comma
-Slice off that next part and set it equal to the city
-Set the rest equal to a temp string
-Slice off the first two characters and set equal to state
-Slice off the last 5 characters and set equal to zip

Seems pretty convoluted, and I'm wondering if there's a better way?

Space Kablooey
May 6, 2009


I don't have python on this machine, but

code:
addr = '115 Berry Lane, Plano, TX 24134'
splitted = str.split(addr, ',') # not sure if addr.split(',') works too

street = splitted[0]
city = splitted[1]

we = str.split(splitted[2]) # will split at the space (' ') character

state = we[0]
zip = we[1]
might be what you are looking for.

Edit: person below me knows what's up.

Space Kablooey fucked around with this message at 20:32 on May 10, 2014

Adbot
ADBOT LOVES YOU

hlfrk414
Dec 31, 2008
code:
>>> s = "115 Berry Lane, Plano, TX 24134"
>>> street, city, state_zip = (_.strip() for _ in s.split(','))
>>> state, zip = state_zip.split(' ')
>>> print street, city, state, zip
115 Berry Lane Plano TX 24134

  • Locked thread