1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-04 22:48:11 -05:00

str -> bytes fixes

This commit is contained in:
Bradlee Speice 2016-08-19 22:09:18 -04:00
parent 88c4401960
commit 96c503a106

View File

@ -1,6 +1,6 @@
import requests import requests
import pandas as pd import pandas as pd
from six import StringIO from six import BytesIO
from metrik.tasks.base import MongoNoBackCreateTask from metrik.tasks.base import MongoNoBackCreateTask
@ -15,7 +15,7 @@ class NasdaqCompanyList(MongoNoBackCreateTask):
csv_bytes = requests.get('http://www.nasdaq.com/screening/' csv_bytes = requests.get('http://www.nasdaq.com/screening/'
'companies-by-region.aspx?&render=download') \ 'companies-by-region.aspx?&render=download') \
.content .content
csv_filelike = StringIO(csv_bytes) csv_filelike = BytesIO(csv_bytes)
company_csv = pd.read_csv(csv_filelike)[ company_csv = pd.read_csv(csv_filelike)[
['Symbol', 'Name', 'LastSale', 'MarketCap', 'Country', 'IPOyear', ['Symbol', 'Name', 'LastSale', 'MarketCap', 'Country', 'IPOyear',
'Sector', 'Industry'] 'Sector', 'Industry']
@ -32,6 +32,6 @@ class NasdaqETFList(MongoNoBackCreateTask):
csv_bytes = requests.get('http://www.nasdaq.com/investing/etfs/' csv_bytes = requests.get('http://www.nasdaq.com/investing/etfs/'
'etf-finder-results.aspx?download=Yes') \ 'etf-finder-results.aspx?download=Yes') \
.content .content
csv_filelike = StringIO(csv_bytes) csv_filelike = BytesIO(csv_bytes)
etf_csv = pd.read_csv(csv_filelike)[['Symbol', 'Name', 'LastSale']] etf_csv = pd.read_csv(csv_filelike)[['Symbol', 'Name', 'LastSale']]
return {'etfs': etf_csv.to_dict(orient='records')} return {'etfs': etf_csv.to_dict(orient='records')}