def dbConnect(self): configReader = ConfigReader() config = configReader.readConfig() host = config.get('Database', "database.host") username = config.get('Database', "database.user") password = config.get('Database', "database.password") dbname = config.get('Database', "database.dbname") conn = MySQLdb.connect(host,username,password,dbname) return conn
def pointError(self,value,i,rowNum): configReader = ConfigReader() config = configReader.readConfig() #Reading parameters from the config file topOffset = config.get('Csv','csv.topOffset') leftOffset = config.get('Csv','csv.leftOffset') print "Column number : %d" %(i+1+int(leftOffset)) print "Row number : %d" %(rowNum+1+int(topOffset)) print "value: %s" % (value)
def readHeader(self): configReader = ConfigReader() config = configReader.readConfig() file = config.get('Csv', 'csv.file') topOffset = config.get('Csv','csv.topOffset') with open(file, "rb") as csvfile: file = csv.reader(csvfile, delimiter=',', quotechar='"') data = [] for lines in file: data.append(lines) columns = data[int(topOffset)] return columns
def __init__(self, fileName): configReader = ConfigReader() config = configReader.readConfig() # reading the parameters from the config file # file = config.get('Csv', 'csv.file') file = fileName self.topOffset = config.get("Csv", "csv.topOffset") self.leftOffset = config.get("Csv", "csv.leftOffset") # opening and reading from the file with open(file, "rb") as csvfile: try: # for removing the byte order mark (BOM ), read the file, decoded the file , and encodeg again without the BOM file = csv.reader( f.read().decode("utf-8-sig").encode("utf-8").splitlines(), delimiter="\t", quotechar='"' ) except: file = csv.reader(csvfile, delimiter=",", quotechar='"') self.data = [] for lines in file: self.data.append(lines) # storing each lines of file in array