You can read files remotely with Frictionless. This is a basic functionality of Frictionless.
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': '中国人'}]
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
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 | '中国人' |
+----+-----------+
Remote control representation
(*, name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, http_timeout: int = 10, http_preload: bool = False) -> None
Specifies the time to wait, if the remote server does not respond before raising an error. The default value is 10.
int
Preloads data to the memory if set to True. It is set to False by default.
bool