-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Prefer requests over urllib2 #3856
Conversation
Probably needs some testing with and without requests installed (quite a few io tests skip for |
resp = urllib2.urlopen(url) | ||
if resp.code == 200: | ||
lines = resp.read() | ||
rs = read_csv(StringIO(bytes_to_str(lines)), index_col=0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, could put this as a helper function, also I seem to have missed out the bytes_to_str
which is presumably there for a reason...
maybe a mention in install.rst of the requests module as an optional dep |
might want to note also that |
I had a go with html, but got some weird lxml error... (removed them in 2nd commit). |
u have to catch |
it's a bit annoying since i actually have to call |
Will have another play later in the week. I actually had a similar thing in the request, checking for exceptions which the user may not have installed (I hid it behind an ImportError: pass). I definitely got into a muddle on that particular Exception... |
i think there needs to be a mother-of-all-read-functions in |
yep...including the options NOT to read (e.g. I think html and read_csv want to read line-by-line), most others (e.g. json), io.data, etc. just need the buffer already read |
html reads the buffer or punts the file-like object to the backend if possible. i think csv is the only iterable one so far |
Do I need to worry about testing in Travis both with and without the requests module? I'm concerned this might have some weird issues either way so push to 0.12? |
there's the |
you could add to all if u want |
see also #2426 |
related #3811 |
@hayd going to resurrect this for primary web access (with fallback to urllib2) and put it io/common if not already there then need to change uses of web acces across io to use this and then docs! |
see #4140 Google BigQuery is dependent on httplib2 is that a viable alternative here? |
@jreback will have a loook |
Not sure what to do with this one (certainly a lot has changed in io.common) |
At the moment we use urllib2 for http requests, this branch prefers to use requests if it's installed. For one thing it means you can read gzipped json, which is more difficult in urllib2:
cc #3804 @jreback
Thoughts?