Edit page in Livemark
(2022-09-19 18:33)

Buffer Scheme

Frictionless supports working with bytes loaded into memory.

Reading Data

You can read Buffer Data using Package/Resource API, for example:

from pprint import pprint
from frictionless import Resource

resource = Resource(b'id,name\n1,english\n2,german', format='csv')
[{'id': 1, 'name': 'english'}, {'id': 2, 'name': 'german'}]

Writing Data

A similiar approach can be used for writing:

from frictionless import Resource

source = Resource(data=[['id', 'name'], [1, 'english'], [2, 'german']])
target = source.write(scheme='buffer', format='csv')
{'name': 'memory',
 'type': 'table',
 'data': [],
 'scheme': 'buffer',
 'format': 'csv',
 'mediatype': 'text/csv'}
[{'id': 1, 'name': 'english'}, {'id': 2, 'name': 'german'}]
It's a beta version of Frictionless Framework (v5). Read Frictionless Framework (v4) docs for a version that is currently installed by default by pip.