Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
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")