Skip to content

Commit

Permalink
feat: allow users paths (eg: "~/files/test.xlsx") (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie authored Jan 31, 2024
1 parent a62fccc commit d7cb26f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/fastexcel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pathlib import Path

import pandas as pd
import polars as pl

from os.path import expanduser

import pyarrow as pa

from ._fastexcel import __version__, _ExcelReader, _ExcelSheet
Expand Down Expand Up @@ -173,12 +177,12 @@ def __repr__(self) -> str:
return self._reader.__repr__()


def read_excel(path: str) -> ExcelReader:
def read_excel(path: Path | str) -> ExcelReader:
"""Opens and loads an excel file.
:param path: The path to the file
"""
return ExcelReader(_read_excel(path))
return ExcelReader(_read_excel(expanduser(path)))


__all__ = ("ExcelReader", "ExcelSheet", "read_excel", "__version__")

0 comments on commit d7cb26f

Please sign in to comment.