docs: def validate_csv(file):
      """Return dialect information about given csv file."""
      try:
          # Detect encoding and dialect
          with file.open() as fp:
              encoding = detect_encoding(fp, default='utf-8')
              sample = fp.read(
                  current_app.config.get('PREVIEWER_CSV_VALIDATION_BYTES', 1024))
              delimiter = csv.Sniffer().sniff(sample.decode(encoding)).delimiter
              is_valid = True
      except Exception as e:
          current_app.logger.debug(
              'File {0} is not valid CSV: {1}'.format(file.uri, e))
          encoding = ''
          delimiter = ''
          is_valid = False
  
      return {
          'delimiter': delimiter,
          'encoding': encoding,
          'is_valid': is_valid
      }