<s> '''<STR_LIT>''' <EOL> import numpy as np <EOL> import pickle as pkl <EOL> import qstkutil . utils as utils <EOL> import os <EOL> import dircache <EOL> import time <EOL> import sys <EOL> def main ( ) : <EOL> print "<STR_LIT>" + str ( time . strftime ( "<STR_LIT>" ) ) <EOL> try : <EOL> rootdir = os . environ [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> print "<STR_LIT>" <EOL> fileExtensionToRemove = "<STR_LIT>" <EOL> listOfInputPaths = list ( ) <EOL> listOfInputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> listOfInputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> listOfInputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> listOfOutputPaths = list ( ) <EOL> listOfOutputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> listOfOutputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> listOfOutputPaths . append ( rootdir + "<STR_LIT>" ) <EOL> for path in listOfOutputPaths : <EOL> if not ( os . access ( path , os . F_OK ) ) : <EOL> os . makedirs ( path ) <EOL> utils . clean_paths ( listOfOutputPaths ) <EOL> if ( len ( listOfInputPaths ) != len ( listOfOutputPaths ) ) : <EOL> print "<STR_LIT>" <EOL> sys . exit ( "<STR_LIT>" ) <EOL> path_ctr = - <NUM_LIT:1> ; <EOL> use_cols = range ( <NUM_LIT:1> , <NUM_LIT:7> + <NUM_LIT:1> ) <EOL> for path in listOfInputPaths : <EOL> path_ctr = path_ctr + <NUM_LIT:1> ; <EOL> stocks_at_this_path = dircache . listdir ( str ( path ) ) <EOL> filtered_names = filter ( lambda x : ( str ( x ) . find ( str ( fileExtensionToRemove ) ) > - <NUM_LIT:1> ) , stocks_at_this_path ) <EOL> filtered_names = map ( lambda x : ( x . partition ( str ( fileExtensionToRemove ) ) [ <NUM_LIT:0> ] ) , filtered_names ) <EOL> stock_ctr = - <NUM_LIT:1> <EOL> for stock in filtered_names : <EOL> stock_ctr = stock_ctr + <NUM_LIT:1> <EOL> print "<STR_LIT>" + str ( path + stock ) <EOL> stock_data = np . loadtxt ( path + stock + "<STR_LIT>" , np . float , None , "<STR_LIT:U+002C>" , None , <NUM_LIT:1> , use_cols ) <EOL> stock_data_shape = stock_data . shape <EOL> f = open ( listOfOutputPaths [ path_ctr ] + filtered_names [ stock_ctr ] + "<STR_LIT>" , "<STR_LIT:wb>" ) <EOL> pkl . dump ( stock_data , f , - <NUM_LIT:1> ) <EOL> f . close ( ) <EOL> print "<STR_LIT>" + str ( time . strftime ( "<STR_LIT>" ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
