Skip to content

Commit

Permalink
Merge pull request #15 from Wesseldr/master
Browse files Browse the repository at this point in the history
removed duplicate line and enhanced parsing cvs format
  • Loading branch information
skillachie authored Feb 22, 2017
2 parents 3a4acb0 + e8e7c55 commit 7dcd83d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions finsymbols/symbol_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ def get_symbol_list(symbol_data, exchange_name):
csv_file = exchange_name + '.csv'

symbol_list = list()
symbol_data = symbol_data.replace('"', "")
symbol_data = re.split("\r?\n", symbol_data)

headers = symbol_data[0]
# symbol,company,sector,industry,headquaters
symbol_data = list(map(lambda x: x.split(","), symbol_data))
symbol_data = list(csv.reader(symbol_data, delimiter=','))
# We need to cut off the the last row because it is a null string
for row in symbol_data[1:-1]:
symbol_data_dict = dict()
symbol_data_dict['symbol'] = row[0]
symbol_data_dict['company'] = row[1]
symbol_data_dict['sector'] = row[6]
symbol_data_dict['industry'] = row[7]
symbol_data_dict['industry'] = row[7]


symbol_list.append(symbol_data_dict)
return symbol_list

Expand Down
4 changes: 2 additions & 2 deletions finsymbols/tests/symbols_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class TestSizeOfList(TestCase):

def test_sp500_size(self):
sp500 = symbols.get_sp500_symbols()
assert len(sp500) == 504, 'len gathered data: {}.\
Expected len: 504'.format(len(sp500))
assert len(sp500) == 505, 'len gathered data: {}.\
Expected len: 505'.format(len(sp500))

def test_amex_not_null(self):
amex = symbols.get_amex_symbols()
Expand Down

0 comments on commit 7dcd83d

Please sign in to comment.