Edit page in Livemark
(2024-01-29 13:37)

Text Resource

A text resource represents a textual file as a markdown document, for example:

from frictionless.resources import TextResource

resource = TextResource(path='article.md')
resource.infer(stats=True)
print(resource)
{'name': 'article',
 'type': 'text',
 'path': 'article.md',
 'scheme': 'file',
 'format': 'md',
 'mediatype': 'text/markdown',
 'encoding': 'utf-8',
 'hash': 'sha256:c3d88243a8bbb2d95787af6edd6b0017791a090d18c80765f92b486ab502cebb',
 'bytes': 20}

We can read the contents:

from frictionless.resources import TextResource

resource = TextResource(path='article.md')
resource.infer(stats=True)
print(resource.read_text())
# Article

Contents