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
  • file_path (str) – Path to the file to load.

  • format_name (str) – Data format name to load. Supported formats are as follows: "csv", "excel", "html", "json", "ltsv", "markdown", "mediawiki", "sqlite", "ssv", "tsv". If the value is None, automatically detect file format from the file_path.

Raises
load()

Loading table data from a file as format_name format. Automatically detect file format if format_name is None.

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

list

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
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

list

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 is None, automatically detect file format from the url.

  • proxies (dict) –

    http/https proxy information.

    See also

    requests proxies

Raises
Example

Load table data from a web page

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

list

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