MCPcopy Create free account
hub / github.com/datapane/datapane / guess_encoding

Function guess_encoding

python-client/src/datapane/common/utils.py:50–58  ·  view source on GitHub ↗
(fn: str)

Source from the content-addressed store, hash-verified

48
49
50def guess_encoding(fn: str) -> str:
51 with open(fn, "rb") as f:
52 detector = UniversalDetector()
53 for line in f.readlines():
54 detector.feed(line)
55 if detector.done:
56 break
57 detector.close()
58 return detector.result["encoding"]
59
60
61def utf_read_text(file: Path) -> str:

Callers 1

load_fileMethod · 0.85

Calls 2

readlinesMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected