mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 20:16:30 +08:00
MAINT: Read text in Python 3 instead of bytes when fetching public data.
Account for byte/string compatibility when consuming response from requests module.
This commit is contained in:
@@ -88,7 +88,7 @@ start_date={start_date}, end_date={end_date}, url={url}""".strip().
|
||||
end_date=end_date,
|
||||
url=res.url))
|
||||
|
||||
return csv.DictReader(res.iter_lines())
|
||||
return csv.DictReader(res.text.splitlines())
|
||||
|
||||
|
||||
def get_benchmark_data(symbol, start_date=None, end_date=None):
|
||||
|
||||
@@ -98,7 +98,7 @@ def get_treasury_source():
|
||||
http://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData\
|
||||
"""
|
||||
res = requests.get(url, stream=True)
|
||||
stream = iter_to_stream(res.iter_lines())
|
||||
stream = iter_to_stream(res.text.splitlines())
|
||||
|
||||
elements = ET.iterparse(stream, ('end', 'start-ns', 'end-ns'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user