sheetwise.core module¶
Main SpreadsheetLLM class integrating all components (Offline Edition).
- class sheetwise.core.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoderCustom JSON encoder to handle NumPy data types.
- default(obj)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- class sheetwise.core.SpreadsheetLLM(compression_params=None, enable_logging=False)[source]¶
Bases:
objectMain class integrating all SheetWise components. Includes Offline SQL and JSON export capabilities.
- load_from_file(filepath)[source]¶
Load spreadsheet from file with robust type detection. Detects file type using magic numbers (signatures) rather than extensions.
- Return type:
- query_sql(df, sql_query, params=None)[source]¶
Run a SQL query against the DataFrame using DuckDB with enhanced security.
- Parameters:
df (
DataFrame) – The dataframe to query (registered as table ‘input_data’)sql_query (
str) – SQL query. Use ‘input_data’ to refer to the dataframe. Example: “SELECT * FROM input_data WHERE Year > ?”params (
Union[list,Dict[str,Any],None]) – Optional parameters for the query to prevent SQL injection. Supports list (for ‘?’) or dict (for ‘$name’) parameters.
- Return type:
- Returns:
Result as a new DataFrame
- encode_to_json(df)[source]¶
Encode compressed spreadsheet data into structured JSON. Ideal for piping into other scripts or APIs.
- Return type:
- compress_and_encode_for_llm(df)[source]¶
Original Markdown encoding (retained for compatibility).
- Return type:
- encode_compressed_for_llm(compressed_result)[source]¶
Generate text representation (Markdown).
- Return type: