Skip to content

Commit 8b9778e

Browse files
committed
WIP helpers module
1 parent 7b10412 commit 8b9778e

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

015_get_stock_prices

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import os
77
import time
88

99
import modules.config_details as conf_info
10+
import modules.tickers_helpers as helpers
1011

1112
# TODO REMOVE THE FOLLOWING TICKERS, LOAD THEM FROM THE CSV FILES INSTEAD
1213
tickers_clothes = [ 'NKE', 'UA', 'ADDYY', 'ADS', 'LULU' ]
@@ -26,31 +27,6 @@ def merge_lists():
2627

2728
##########################################################################
2829
##########################################################################
29-
# import os
30-
import glob
31-
32-
def process_tickers_lists_csv_files():
33-
all_tickers_all_files = []
34-
for file in glob.glob('./data/conf/tickers_*.csv'):
35-
print 'Found this:', file
36-
tickers_to_process = get_tickers_from_csv_file(file)
37-
print ' >>> Found tickers:', tickers_to_process
38-
all_tickers_all_files.extend(tickers_to_process)
39-
print 'ALL OF ALL:', all_tickers_all_files
40-
41-
import csv
42-
def get_tickers_from_csv_file(filename):
43-
all_tickers_for_file = []
44-
with open(filename, 'rb') as csvfile:
45-
dialect = csv.Sniffer().sniff(csvfile.read(), delimiters=':')
46-
csvfile.seek(0)
47-
reader = csv.reader(csvfile, dialect)
48-
for row in reader:
49-
print ' Current row:', '_SEPARATOR_'.join(row)
50-
current_tickers = row[1].split(',')
51-
print ' Tickers:', current_tickers
52-
all_tickers_for_file.extend(current_tickers)
53-
return all_tickers_for_file
5430

5531
##########################################################################
5632
##########################################################################
@@ -98,5 +74,5 @@ def get_after_2016_02(tickers, store_dir):
9874
# get_before_2016_02(merge_lists(),conf_info.stock_prices_dir)
9975
# get_after_2016_02(merge_lists(),conf_info.stock_prices_dir)
10076

101-
process_tickers_lists_csv_files()
77+
print helpers.get_all_tickers_lists_csv_files()
10278

modules/__init__.pyc

-153 Bytes
Binary file not shown.

modules/tickers_helpers.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
import glob
3+
4+
def get_all_tickers_lists_csv_files():
5+
all_tickers_all_files = []
6+
for file in glob.glob('./data/conf/tickers_*.csv'):
7+
# print 'Found this:', file
8+
tickers_to_process = get_tickers_from_csv_file(file)
9+
# print ' >>> Found tickers:', tickers_to_process
10+
all_tickers_all_files.extend(tickers_to_process)
11+
# print 'ALL OF ALL:', all_tickers_all_files
12+
return all_tickers_all_files
13+
14+
import csv
15+
def get_tickers_from_csv_file(filename):
16+
all_tickers_for_file = []
17+
with open(filename, 'rb') as csvfile:
18+
dialect = csv.Sniffer().sniff(csvfile.read(), delimiters=':')
19+
csvfile.seek(0)
20+
reader = csv.reader(csvfile, dialect)
21+
for row in reader:
22+
current_tickers = row[1].split(',')
23+
# print ' Tickers:', current_tickers
24+
all_tickers_for_file.extend(current_tickers)
25+
return all_tickers_for_file

0 commit comments

Comments
 (0)