Skip to content

Commit 0d6a223

Browse files
committed
prepare for identify by path
1 parent 786adb5 commit 0d6a223

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

hdxms_datasets/formats.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
from typing import Callable, Optional
23
from dataclasses import dataclass
34
import narwhals as nw
@@ -220,9 +221,24 @@ def hxms_is_aggregated(df: nw.DataFrame) -> bool:
220221
FORMAT_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)

0 commit comments

Comments
 (0)