5.1. Table Loader Wrapper Classes¶
5.1.1. File Loader Wrapper¶
- class pytablereader.TableFileLoader(file_path, format_name=None, encoding=None, type_hint_rules=None)[source]¶
Loader class to loading tables from a file.
- Parameters:
- Raises:
pytablereader.InvalidFilePathError – If
file_pathis an invalid file path.pytablereader.LoaderNotFoundError – If an appropriate loader not found for loading the file.
- load()¶
Loading table data from a file as
format_nameformat. Automatically detect file format ifformat_nameisNone.- Returns:
Loaded table data iterator.
- Return type:
TableDataiterator
- classmethod get_format_names()[source]¶
- Returns:
Available format names. These names can use by
TableFileLoaderclass constructor.- Return type:
- Example:
>>> from pytablereader import TableFileLoader >>> for format_name in TableFileLoader.get_format_names(): ... print(format_name) ... csv excel html json json_lines jsonl ldjson ltsv markdown mediawiki ndjson sqlite ssv tsv
5.1.2. Text Loader Wrapper¶
- class pytablereader.TableTextLoader(source: str, format_name: str, encoding: str | None = None, type_hint_rules=None)[source]¶
Loader class to loading tables from URL.
- Parameters:
url (str) – URL to load.
format_name (str) – Data format name to load. Supported formats can be get by
get_format_names()proxies (dict) –
http/https proxy information.
See also
- Raises:
pytablereader.LoaderNotFoundError – If an appropriate loader not found for loading the URL.
- load()¶
Load tables from text as
format_nameformat.- Returns:
Loaded table data iterator.
- Return type:
TableDataiterator
- classmethod get_format_names() Sequence[str][source]¶
- Returns:
Available format names. These names can use by
TableTextLoaderclass constructor.- Return type:
- Example:
>>> from pytablereader import TableTextLoader >>> for format_name in TableTextLoader.get_format_names(): ... print(format_name) ... csv excel html json json_lines jsonl ldjson ltsv markdown mediawiki ndjson sqlite ssv tsv
5.1.3. URL Loader Wrapper¶
- class pytablereader.TableUrlLoader(url, format_name=None, encoding=None, type_hint_rules=None, proxies=None)[source]¶
Loader class to loading tables from URL.
- Parameters:
url (str) – URL to load.
format_name (str) – Data format name to load. Supported formats are:
"csv","excel","html","json","ltsv","markdown","mediawiki","sqlite","ssv","tsv". If the value isNone, automatically detect file format from theurl.proxies (dict) –
http/https proxy information.
See also
- Raises:
pytablereader.LoaderNotFoundError – If an appropriate loader not found for loading the URL.
pytablereader.HTTPError – If loader received an HTTP error when access to the URL.
- Example:
- load()¶
Load tables from URL as
format_nameformat.- Returns:
Loaded table data iterator.
- Return type:
TableDataiterator
- classmethod get_format_names()[source]¶
- Returns:
Available format names. These names can use by
TableUrlLoaderclass constructor.- Return type:
- Example:
>>> from pytablereader import TableUrlLoader >>> for format_name in TableUrlLoader.get_format_names(): ... print(format_name) ... csv excel html json json_lines jsonl ldjson ltsv markdown mediawiki ndjson sqlite ssv tsv