|
sund posted:Yeah, it'll be caching writes for you. 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 |
# ? May 6, 2014 04:51 |
|
|
# ? May 9, 2024 11:43 |
|
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:
|
# ? May 6, 2014 09:01 |
|
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:
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 |
# ? May 6, 2014 17:10 |
|
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.
|
# ? May 7, 2014 21:49 |
|
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!
|
# ? May 7, 2014 22:16 |
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. 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.
|
|
# ? May 7, 2014 22:26 |
|
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:
salisbury shake fucked around with this message at 00:22 on May 8, 2014 |
# ? May 8, 2014 00:03 |
|
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.
|
# ? May 8, 2014 03:51 |
|
Regarding using the Google Search API, is this something that would set me up to do that?
|
# ? May 8, 2014 04:40 |
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
|
|
# ? May 8, 2014 08:19 |
|
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.
|
# ? May 8, 2014 17:44 |
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?
|
|
# ? May 8, 2014 18:03 |
|
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: So that rules that out, right? the fucked around with this message at 18:09 on May 8, 2014 |
# ? May 8, 2014 18:05 |
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.
|
|
# ? May 8, 2014 18:08 |
|
Why is this happening?code:
code:
the fucked around with this message at 18:43 on May 8, 2014 |
# ? May 8, 2014 18:13 |
|
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'], 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: 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:
quote:[{u'categories': [[u'Doctors', u'physicians'], Which is a list. Great, I thought, let me try to access the first part of that list: Python code:
quote:{u'categories': [[u'Doctors', u'physicians'], Which is a dict And then finally Python code:
code:
the fucked around with this message at 21:04 on May 8, 2014 |
# ? May 8, 2014 19:47 |
|
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?
|
# ? May 8, 2014 21:02 |
|
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:
code:
|
# ? May 8, 2014 21:06 |
|
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:
OnceIWasAnOstrich fucked around with this message at 21:20 on May 8, 2014 |
# ? May 8, 2014 21:13 |
|
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 |
# ? May 8, 2014 21:18 |
the posted:Why is this happening? Yeah always use 'pip install' over easy_install
|
|
# ? May 8, 2014 21:27 |
|
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.
|
# ? May 9, 2014 05:16 |
|
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.
|
# ? May 9, 2014 05:21 |
|
https://www.youtube.com/watch?v=UPw-3e_pzqU
|
# ? May 9, 2014 05:28 |
|
the posted:I'm using the Yelp API, and it looks like it's returning things as a unicode dict? Gross.
|
# ? May 9, 2014 18:13 |
|
Cultural Imperial posted:What's the coolest thing any of you have done with a decorator? 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.
|
# ? May 9, 2014 19:22 |
|
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? 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).
|
# ? May 9, 2014 19:40 |
|
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 Any help would be appreciated, thanks!
|
# ? May 9, 2014 20:39 |
|
Try apt-get install zlib1g-dev?
|
# ? May 9, 2014 22:42 |
|
Vicar posted:Try apt-get install zlib1g-dev? Did that. Install of lxml still failed with the same error.
|
# ? May 9, 2014 23:51 |
|
There's a goon at Continuum right? If you're the one who added a streamhandler to the root logger in numba 0.11... 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 |
# ? May 10, 2014 00:29 |
|
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:
code:
edit: I can use Python code:
the fucked around with this message at 04:42 on May 10, 2014 |
# ? May 10, 2014 04:31 |
|
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')).
|
# ? May 10, 2014 04:47 |
|
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.
|
# ? May 10, 2014 04:50 |
|
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... I think that's a bug that will go away if you update to a newer numba. That was my experience anyway.
|
# ? May 10, 2014 09:57 |
|
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... 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.
|
# ? May 10, 2014 17:05 |
|
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...).
|
# ? May 10, 2014 18:45 |
|
Lets say I have a string that's likecode:
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?
|
# ? May 10, 2014 20:21 |
|
I don't have python on this machine, butcode:
Edit: person below me knows what's up. Space Kablooey fucked around with this message at 20:32 on May 10, 2014 |
# ? May 10, 2014 20:30 |
|
|
# ? May 9, 2024 11:43 |
|
code:
|
# ? May 10, 2014 20:30 |