{"record":{"id":"2640a2c06dd29388","repo":"binary-husky/gpt_academic","slug":"unsupported-format-path-suffix-supported","errorCode":null,"errorMessage":"Unsupported format: {path.suffix}. Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}","messagePattern":"Unsupported format: (.+?)\\. Supported: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"crazy_functions/doc_fns/read_fns/excel_reader.py","lineNumber":82,"sourceCode":"                return result['encoding'] or 'utf-8'\n        except Exception as e:\n            self.logger.warning(f\"Encoding detection failed: {e}. Using utf-8\")\n            return 'utf-8'\n\n    def _validate_file(self, file_path: Union[str, Path]) -> Path:\n        path = Path(file_path).resolve()\n\n        if not path.exists():\n            raise ValueError(f\"File not found: {path}\")\n\n        if not path.is_file():\n            raise ValueError(f\"Not a file: {path}\")\n\n        if not os.access(path, os.R_OK):\n            raise PermissionError(f\"No read permission: {path}\")\n\n        if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:\n            raise ValueError(\n                f\"Unsupported format: {path.suffix}. \"\n                f\"Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}\"\n            )\n\n        return path\n\n    def _format_value(self, value: Any) -> str:\n        if pd.isna(value) or value is None:\n            return ''\n        if isinstance(value, (int, float)):\n            return str(value)\n        return str(value).strip()\n\n    def _process_chunk(self, chunk: pd.DataFrame, columns: Optional[List[str]] = None, sheet_name: str = '') -> str:\n        \"\"\"处理数据块，新增sheet_name参数\"\"\"\n        try:\n            if columns:\n                chunk = chunk[columns]","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/crazy_functions/doc_fns/read_fns/excel_reader.py#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"Generic 'upload any doc' pipelines routing every file to the Excel extractor; Excel temp lock files '~$report.xlsx'; files downloaded without extension.","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"],"exampleFix":"// before\nextractor.read_text('report.xlsb')  # .xlsb not in SUPPORTED_EXTENSIONS\n\n// after\n# route by extension\nreaders = {'.pdf': pdf_reader, '.xlsx': excel_extractor, '.xlsb': ...}\nreader = readers.get(path.suffix.lower())","handlingStrategy":"type-guard","validationCode":"from crazy_functions.doc_fns.read_fns.excel_reader import ExcelTextExtractor\n\nif fp.suffix.lower() not in ExcelTextExtractor.SUPPORTED_EXTENSIONS:\n    route_to_appropriate_reader(fp)","typeGuard":"EXCEL_EXTS = {'.xlsx', '.xls', '.csv', '.tsv', '.xlsm', '.xltx', '.xltm', '.ods'}\n\ndef is_excel_like(fp) -> bool:\n    return str(fp).lower().endswith(tuple(EXCEL_EXTS))","tryCatchPattern":"try:\n    text = extractor.read_text(fp)\nexcept ValueError as e:\n    if str(e).startswith('Unsupported format'):\n        return skip_or_reroute(fp)\n    raise","preventionTips":["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"],"tags":["file-validation","format-check","excel","routing","python"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}