File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ from pathlib import Path
12from typing import Callable , Optional
23from dataclasses import dataclass
34import narwhals as nw
@@ -220,9 +221,24 @@ def hxms_is_aggregated(df: nw.DataFrame) -> bool:
220221FORMAT_LUT = {fmt .name : fmt for fmt in FORMATS }
221222
222223
223- def identify_format (df : nw .DataFrame ) -> Optional [FormatSpec ]:
224+ def identify_format_from_path (path : Path ) -> Optional [FormatSpec ]:
225+ """Identify format from file path by reading a sample of the data."""
226+
227+ raise NotImplementedError ("Function not yet implemented" )
228+
229+
230+ def identify_format_from_df (df : nw .DataFrame ) -> Optional [FormatSpec ]:
224231 """Identify format from DataFrame columns"""
225232 for fmt in FORMATS :
226233 if fmt .matches (df ):
227234 return fmt
228235 return None
236+
237+
238+ def identify_format (src : nw .DataFrame | Path ) -> Optional [FormatSpec ]:
239+ """Identify format from DataFrame columns"""
240+ if isinstance (src , Path ):
241+ return identify_format_from_path (src )
242+
243+ elif isinstance (src , nw .DataFrame ):
244+ return identify_format_from_df (src )
You can’t perform that action at this time.
0 commit comments