Simple case detector
gridgulp.detectors.simple_case_detector ¶
Simple case detector for identifying single-table sheets.
This module provides fast detection of sheets that contain only a single table, allowing the system to avoid expensive vision processing for simple cases.
SimpleTableResult
dataclass
¶
SimpleTableResult(is_simple_table: bool, table_range: str | None = None, confidence: float = 0.0, has_headers: bool = True, reason: str = '')
Result of simple table detection.
SimpleCaseDetector ¶
Detects sheets containing a single, continuous table starting from A1.
Initialize the simple case detector.
Parameters:
-
max_empty_threshold(int, default:3) –Maximum consecutive empty rows/cols allowed within table
Source code in src/gridgulp/detectors/simple_case_detector.py
detect_simple_table ¶
Detect if sheet contains a simple single table case.
A simple table case is defined as: 1. Data starts at or near A1 (within first 3 rows/cols) 2. Continuous data region with no empty rows/columns 3. Rectangular shape 4. Optional headers in first row
Parameters:
-
sheet_data(SheetData) –Sheet data to analyze
Returns:
-
SimpleTableResult–SimpleTableResult with detection outcome
Source code in src/gridgulp/detectors/simple_case_detector.py
convert_to_table_info ¶
convert_to_table_info(result: SimpleTableResult, sheet_name: str, sheet_data: Optional[SheetData] = None) -> TableInfo | None
Convert simple table result to TableInfo.
Parameters:
-
result(SimpleTableResult) –SimpleTableResult from detection
-
sheet_name(str) –Name of the sheet
-
sheet_data(Optional[SheetData], default:None) –Sheet data for header extraction (optional)
Returns:
-
TableInfo | None–TableInfo if simple table detected, None otherwise