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_path
is 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_name
format. Automatically detect file format ifformat_name
isNone
.- Returns
Loaded table data iterator.
- Return type
TableData
iterator
- classmethod get_format_names()[source]¶
- Returns
Available format names. These names can use by
TableFileLoader
class 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: Optional[str] = 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_name
format.- Returns
Loaded table data iterator.
- Return type
TableData
iterator
- classmethod get_format_names() Sequence[str] [source]¶
- Returns
Available format names. These names can use by
TableTextLoader
class 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_name
format.- Returns
Loaded table data iterator.
- Return type
TableData
iterator
- classmethod get_format_names()[source]¶
- Returns
Available format names. These names can use by
TableUrlLoader
class 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