def validate_csv(file):
try:<EOL><INDENT>with file.open() as fp:<EOL><INDENT>encoding = detect_encoding(fp, default='<STR_LIT:utf-8>')<EOL>sample = fp.read(<EOL>current_app.config.get('<STR_LIT>', <NUM_LIT>))<EOL>delimiter = csv.Sniffer().sniff(sample.decode(encoding)).delimiter<EOL>is_valid = True<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>current_app.logger.debug(<EOL>'<STR_LIT>'.format(file.uri, e))<EOL>encoding = '<STR_LIT>'<EOL>delimiter = '<STR_LIT>'<EOL>is_valid = False<EOL><DEDENT>return {<EOL>'<STR_LIT>': delimiter,<EOL>'<STR_LIT>': encoding,<EOL>'<STR_LIT>': is_valid<EOL>}<EOL>
Return dialect information about given csv file.