def loadEDWGSAAdvFromCSVFile(filename, pattern, adapter, LIMIT_NUM_MATCHING_TRANSACTIONS): try: logger.error('EDWGSAAdv reader opened:' + filename) transactions = [] with open(filename, 'rb') as f: basename = os.path.basename(filename) reader = csv.reader(f) logger.error('EDWGSAAdv reader opened:' + filename) n = len(transactions) i = 0 for row in reader: tr = RawTransaction("spud") tr.data = row try: bt = BasicTransaction(adapter, tr, basename) if (pattern): result = re.search(pattern, bt.getSearchMemento()) else: result = True if (result): if (bt.isValidTransaction()): transactions.append(bt) i = i + 1 if (i + n) > LIMIT_NUM_MATCHING_TRANSACTIONS: break except: print "Error on this row:" print repr(row) return transactions except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror)
def loadGSAAdvFromCSVFile(filename,pattern,adapter,LIMIT_NUM_MATCHING_TRANSACTIONS): try: logger.error('GSAAdv reader opened:'+filename) transactions = [] with open(filename, 'rb') as f: basename = os.path.basename(filename) reader = csv.reader(f) logger.error('GSAAdv reader opened:'+filename) n = len(transactions) i = 0 for row in reader: tr = RawTransaction("spud") tr.data = row; try: bt = BasicTransaction(adapter,tr,basename) if (pattern): result = re.search(pattern, bt.getSearchMemento()) else: result = True if (result): if (bt.isValidTransaction()): transactions.append(bt) i = i + 1 if (i+n) > LIMIT_NUM_MATCHING_TRANSACTIONS: break except: print "Error on this row:" print repr(row) return transactions except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror)
def loadFromCSVString(csv_string,adapter,basename): transactions = [] reader = csv.reader(csv_string.splitlines()) n = len(transactions) i = 0 notFoundFirstRecord = True for row in reader: logger.error("row ="+repr(row)) tr = RawTransaction("spud") tr.data = row; try: bt = BasicTransaction(adapter,tr,basename) logger.error('BT:'+repr(bt)) # logger.flush # logger.error('AT:'+repr(float(bt.dict[PRICE]))) # logger.error('XT:'+repr(int(bt.dict[UNITS]))) # if (bt.isValidTransaction()): transactions.append(bt) i = i + 1 except: logger.error('ERROR:'+repr(sys.exc_info()[0])) print "error "+repr(sys.exc_info()[0]) print "Error on this row:" print repr(row) logger.error('number returned:'+str(i)) return transactions
def loadLabequipmentFromCSVFile(filename, pattern, adapter, LIMIT_NUM_MATCHING_TRANSACTIONS): try: transactions = [] with open(filename, 'rb') as f: basename = os.path.basename(filename) reader = csv.reader(f) logger.info('Lab Equipment reader opened:' + filename) n = len(transactions) i = 0 notFoundFirstRecord = True for row in reader: tr = RawTransaction("spud") tr.data = row try: if (notFoundFirstRecord): result = False notFoundFirstRecord = False else: bt = BasicTransaction(adapter, tr, basename) if (pattern): result = re.search(pattern, bt.getSearchMemento()) else: result = True if (result): if (bt.isValidTransaction()): transactions.append(bt) i = i + 1 if (i + n) > LIMIT_NUM_MATCHING_TRANSACTIONS: break except: print "Error on this row:" print repr(row) logger.info('number returned:' + str(i)) return transactions except IOError as e: logger.error("I/O error({0}): {1}".format(e.errno, e.strerror)) print "I/O error({0}): {1}".format(e.errno, e.strerror) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stderr) logger.error("don't know what went wrong here2")
def loadRevAucFromCSVFile(filename,pattern,adapter,LIMIT_NUM_MATCHING_TRANSACTIONS): try: transactions = [] with open(filename, 'rb') as f: basename = os.path.basename(filename) reader = csv.reader(f) logger.info('RevAuc reader opened:'+filename) n = len(transactions) i = 0 notFoundFirstRecord = True for row in reader: tr = RawTransaction("spud") tr.data = row; try: if (notFoundFirstRecord): result = False notFoundFirstRecord = False; else: bt = BasicTransaction(adapter,tr,basename) if (pattern): result = re.search(pattern, bt.getSearchMemento()) else: result = True if (result): if (bt.isValidTransaction()): transactions.append(bt) i = i + 1 if (i+n) > LIMIT_NUM_MATCHING_TRANSACTIONS: break except: print "Error on this row:" print repr(row) logger.info('number returned:'+str(i)) return transactions except IOError as e: logger.error("I/O error({0}): {1}".format(e.errno, e.strerror)) print "I/O error({0}): {1}".format(e.errno, e.strerror) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stderr) logger.error("don't know what went wrong here")