(fileName,file_contents,CRLF=True,LTRB=True,withTranscription=False,withConfidence=False,imWidth=0,imHeight=0)
This function validates that all lines of the file calling the Line validation function for each line
This function validates that all lines of the file calling the Line validation function for each line
This function validates that all lines of the file calling the Line validation function for each line
def validate_lines_in_file(fileName,file_contents,CRLF=True,LTRB=True,withTranscription=False,withConfidence=False,imWidth=0,imHeight=0):
    """
    This function validates that all lines of the file calling the Line validation function for each line
    """
    utf8File = decode_utf8(file_contents)
    if (utf8File is None) :
        raise Exception("The file %s is not UTF-8" %fileName)

    lines = utf8File.split( "\r\n" if CRLF else "\n" )
    for line in lines:
        line = line.replace("\r","").replace("\n","")
        if(line != ""):
            try:
                validate_tl_line(line,LTRB,withTranscription,withConfidence,imWidth,imHeight)
            except Exception as e:
                raise Exception(("Line in sample not valid. Sample: %s Line: %s Error: %s" %(fileName,line,str(e))).encode('utf-8', 'replace'))
def validate_lines_in_file ( fileName , file_contents , CRLF = True , LTRB = True , withTranscription = False , withConfidence = False , imWidth = 0 , imHeight = 0 ) : utf8File = decode_utf8 ( file_contents ) if ( utf8File is None ) : raise Exception ( "The file %s is not UTF-8" % fileName ) lines = utf8File . split ( "\r\n" if CRLF else "\n" ) for line in lines : line = line . replace ( "\r" , "" ) . replace ( "\n" , "" ) if ( line != "" ) : try : validate_tl_line ( line , LTRB , withTranscription , withConfidence , imWidth , imHeight ) except Exception as e : raise Exception ( ( "Line in sample not valid. Sample: %s Line: %s Error: %s" % ( fileName , line , str ( e ) ) ) . encode ( 'utf-8' , 'replace' ) )