class Coupon: couponDeirectory = '' couponDatas = [] def __init__(self,couponDeirectory): self.couponDeirectory = couponDeirectory self.csvReader = CSVReader() self.__generateCouponDatas() def __generateCouponDatas(self): filesDirectory = self.couponDeirectory for dirname, dirnames, filenames in os.walk(filesDirectory): # print path to all filenames. for filename in filenames: fileNamePath = os.path.join(dirname, filename) fileNamePath = os.path.normpath(fileNamePath) filename = filename.split('.')[0] fileDatas = self.__getCSVData(fileNamePath) couponData = [] couponData.append(filename) couponData.append(fileDatas) self.couponDatas.append(couponData) def __getCSVData(self,fileNamePath): self.csvReader.setFileName(fileNamePath) return self.csvReader.readCsv() def getCouponDatas(self): return self.couponDatas