def detect(stream, delimiter=DEFAULT_DELIMITER): """Returns True if given stream is valid CSV.""" try: csv.Sniffer().sniff(stream, delimiters=delimiter) return True except (csv.Error, TypeError): return False
def detect(stream): """Returns True if given stream is valid TSV.""" try: csv.Sniffer().sniff(stream, delimiters='\t') return True except (csv.Error, TypeError): return False
def detect(stream): """Returns True if given stream is valid CSV.""" try: csv.Sniffer().sniff(stream) return True except csv.Error: return False