binary-husky/gpt_academic · warning · ValueError
Unsupported format: {path.suffix}. Supported: {', '.join(sor
Error message
Unsupported format: {path.suffix}. Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))} What it means
Final check in ExcelTextExtractor._validate_file: the file's lowercased suffix is not in SUPPORTED_EXTENSIONS ({'.xlsx','.xls','.csv','.tsv','.xlsm','.xltx','.xltm','.ods'}), so ValueError lists the offending suffix and the supported set. Note this is extension-based only — a zip renamed to .xlsx passes this check and fails later.
Source
Thrown at crazy_functions/doc_fns/read_fns/excel_reader.py:82
return result['encoding'] or 'utf-8'
except Exception as e:
self.logger.warning(f"Encoding detection failed: {e}. Using utf-8")
return 'utf-8'
def _validate_file(self, file_path: Union[str, Path]) -> Path:
path = Path(file_path).resolve()
if not path.exists():
raise ValueError(f"File not found: {path}")
if not path.is_file():
raise ValueError(f"Not a file: {path}")
if not os.access(path, os.R_OK):
raise PermissionError(f"No read permission: {path}")
if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:
raise ValueError(
f"Unsupported format: {path.suffix}. "
f"Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}"
)
return path
def _format_value(self, value: Any) -> str:
if pd.isna(value) or value is None:
return ''
if isinstance(value, (int, float)):
return str(value)
return str(value).strip()
def _process_chunk(self, chunk: pd.DataFrame, columns: Optional[List[str]] = None, sheet_name: str = '') -> str:
"""处理数据块,新增sheet_name参数"""
try:
if columns:
chunk = chunk[columns]View on GitHub (pinned to d6bde0fa54)
Solutions
- Route files by type: use the reader matching the extension (this extractor is Excel/CSV/TSV only)
- Rename genuinely supported content that lost its extension, or pass a path with the correct suffix
- Strip Excel owner lock-file prefixes ('~$') and skip them in directory scans
- If you must accept extension-less files, copy to a temp file with the right suffix before validating
Example fix
// before
extractor.read_text('report.xlsb') # .xlsb not in SUPPORTED_EXTENSIONS
// after
# route by extension
readers = {'.pdf': pdf_reader, '.xlsx': excel_extractor, '.xlsb': ...}
reader = readers.get(path.suffix.lower()) Defensive patterns
Strategy: type-guard
Validate before calling
from crazy_functions.doc_fns.read_fns.excel_reader import ExcelTextExtractor
if fp.suffix.lower() not in ExcelTextExtractor.SUPPORTED_EXTENSIONS:
route_to_appropriate_reader(fp) Type guard
EXCEL_EXTS = {'.xlsx', '.xls', '.csv', '.tsv', '.xlsm', '.xltx', '.xltm', '.ods'}
def is_excel_like(fp) -> bool:
return str(fp).lower().endswith(tuple(EXCEL_EXTS)) Try / catch
try:
text = extractor.read_text(fp)
except ValueError as e:
if str(e).startswith('Unsupported format'):
return skip_or_reroute(fp)
raise Prevention
- Route by extension at the dispatcher level before choosing a reader
- Skip '~$'-prefixed Excel lock files in directory scans
- Normalize suffix with .lower() yourself; the check is case-insensitive but trailing spaces break it
When it happens
Trigger: Feeding .pdf/.json/.txt or extension-less files to the Excel reader; case variants are fine (.XLSX passes) but '.xls ' with trailing space does not; old .xlt/.xlw templates are rejected.
Common situations: Generic 'upload any doc' pipelines routing every file to the Excel extractor; Excel temp lock files '~$report.xlsx'; files downloaded without extension.
Related errors
- 不支持的格式: {path.suffix}. 支持的格式: {', '.join(sorted(self.SUPPORT
- File not found: {path}
- Not a file: {path}
- No read permission: {path}
- 文件不存在: {path}
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/2640a2c06dd29388.
Report an issue: GitHub.