Edit page in Livemark
(2024-11-07 15:17)

Remote Scheme

You can read files remotely with Frictionless. This is a basic functionality of Frictionless.

Reading Data

You can read using Package/Resource, for example:

from pprint import pprint
from frictionless import Resource

path='https://raw.githubusercontent.com/frictionlessdata/frictionless-py/master/data/table.csv'
resource = Resource(path=path)
pprint(resource.read_rows())
[{'id': 1, 'name': 'english'}, {'id': 2, 'name': '中国人'}]

Writing Data

A similar approach can be used for writing:

from frictionless import Resource

resource = Resource(path='data/table.csv')
resource.write('https://example.com/data/table.csv') # will POST the file to the server

Configuration

There is a Control to configure remote data, for example:

from frictionless import Resource
from frictionless.plugins.remote import RemoteControl

control = RemoteControl(http_timeout=10)
path='https://raw.githubusercontent.com/frictionlessdata/frictionless-py/master/data/table.csv'
resource = Resource(path=path, control=control)
print(resource.to_view())
+----+-----------+
| id | name      |
+====+===========+
|  1 | 'english' |
+----+-----------+
|  2 | '中国人'     |
+----+-----------+

Reference

schemes.RemoteControl (class)

schemes.RemoteControl (class)

Remote control representation

Signature

(*, name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, http_timeout: int = 10, http_preload: bool = False) -> None

Parameters

  • name (Optional[str])
  • title (Optional[str])
  • description (Optional[str])
  • http_timeout (int)
  • http_preload (bool)

schemes.remoteControl.http_timeout (property)

Specifies the time to wait, if the remote server does not respond before raising an error. The default value is 10.

Signature

int

schemes.remoteControl.http_preload (property)

Preloads data to the memory if set to True. It is set to False by default.

Signature

bool