ragflow/deepdoc/parser
Jay Xu 569ab011c4
Add fallback to use 'calamine' parse engine in excel_parser.py (#9374)
### What problem does this PR solve?

add fallback to `calamine` engine when parse error raised using the
default `openpyxl` / `xlrd` engine.
e.g. the following error can be fixed:
```
Traceback (most recent call last):
  File "/ragflow/deepdoc/parser/excel_parser.py", line 53, in _load_excel_to_workbook
    df = pd.read_excel(file_like_object)
  File "/ragflow/.venv/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 495, in read_excel
    io = ExcelFile(
  File "/ragflow/.venv/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 1567, in __init__
    self._reader = self._engines[engine](
  File "/ragflow/.venv/lib/python3.10/site-packages/pandas/io/excel/_xlrd.py", line 46, in __init__
    super().__init__(
  File "/ragflow/.venv/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 573, in __init__
    self.book = self.load_workbook(self.handles.handle, engine_kwargs)
  File "/ragflow/.venv/lib/python3.10/site-packages/pandas/io/excel/_xlrd.py", line 63, in load_workbook
    return open_workbook(file_contents=data, **engine_kwargs)
  File "/ragflow/.venv/lib/python3.10/site-packages/xlrd/__init__.py", line 172, in open_workbook
    bk = open_workbook_xls(
  File "/ragflow/.venv/lib/python3.10/site-packages/xlrd/book.py", line 68, in open_workbook_xls
    bk.biff2_8_load(
  File "/ragflow/.venv/lib/python3.10/site-packages/xlrd/book.py", line 641, in biff2_8_load
    cd.locate_named_stream(UNICODE_LITERAL(qname))
  File "/ragflow/.venv/lib/python3.10/site-packages/xlrd/compdoc.py", line 398, in locate_named_stream
    result = self._locate_stream(
  File "/ragflow/.venv/lib/python3.10/site-packages/xlrd/compdoc.py", line 429, in _locate_stream
    raise CompDocError("%s corruption: seen[%d] == %d" % (qname, s, self.seen[s]))
xlrd.compdoc.CompDocError: Workbook corruption: seen[2] == 4
```

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
2025-08-12 12:41:33 +08:00
..
resume Fix: resolve regex library warnings (#7782) 2025-05-22 10:06:28 +08:00
__init__.py Update comments (#4569) 2025-01-21 20:52:28 +08:00
docx_parser.py Refactor parser code (#9042) 2025-07-25 12:04:07 +08:00
excel_parser.py Add fallback to use 'calamine' parse engine in excel_parser.py (#9374) 2025-08-12 12:41:33 +08:00
figure_parser.py Perf: test llm before RAPTOR. (#8897) 2025-07-17 16:48:50 +08:00
html_parser.py Refa: add result to callback for agent tool use. (#9137) 2025-08-01 21:49:39 +08:00
json_parser.py Feat: parsing supports jsonl or ldjson format (#9087) 2025-07-30 09:48:20 +08:00
markdown_parser.py Fix: fixed context loss caused by separating markdown tables from original text (#8844) 2025-07-15 13:03:01 +08:00
pdf_parser.py Perf: ignore concate between rows. (#8507) 2025-06-26 14:55:37 +08:00
ppt_parser.py fix "TypeError: '<' not supported between instances of 'Emu' and 'Non… (#9209) 2025-08-04 16:07:03 +08:00
txt_parser.py Fix: delimiter issue. (#5720) 2025-03-06 17:51:22 +08:00
utils.py Update comments (#4569) 2025-01-21 20:52:28 +08:00