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

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