def _get_testrun_from_csv(file_obj, csv_reader):
    """Tries to find the testrun id in  Polarion exported csv file."""
    file_obj.seek(0)
    search_str = r'TEST_RECORDS:\("[^/]+/([^"]+)"'
    testrun_id = None
    too_far = False
    for row in csv_reader:
        for col in row:
            if not col:
                continue
            field = col.strip().replace('"', "").replace(" ", "").lower()
            if field == "id":
                # we are too far, tests results start here
                too_far = True
                break
            search = re.search(search_str, col)
            try:
                testrun_id = search.group(1)
            except AttributeError:
                continue
            else:
                break
        if testrun_id or too_far:
            break

    return testrun_id
def _get_testrun_from_csv ( file_obj , csv_reader ) : file_obj . seek ( 0 ) search_str = r'TEST_RECORDS:\("[^/]+/([^"]+)"' testrun_id = None too_far = False for row in csv_reader : for col in row : if not col : continue field = col . strip ( ) . replace ( '"' , "" ) . replace ( " " , "" ) . lower ( ) if field == "id" : too_far = True break search = re . search ( search_str , col ) try : testrun_id = search . group ( 1 ) except AttributeError : continue else : break if testrun_id or too_far : break return testrun_id
Tries to find the testrun id in  Polarion exported csv file.