MCPcopy Create free account
hub / github.com/numpy/numpy / openfile

Function openfile

numpy/ma/mrecords.py:649–666  ·  view source on GitHub ↗

Opens the file handle of file `fname`.

(fname)

Source from the content-addressed store, hash-verified

647
648
649def openfile(fname):
650 """
651 Opens the file handle of file `fname`.
652
653 """
654 # A file handle
655 if hasattr(fname, 'readline'):
656 return fname
657 # Try to open the file and guess its type
658 try:
659 f = open(fname)
660 except FileNotFoundError as e:
661 raise FileNotFoundError(f"No such file: '{fname}'") from e
662 if f.readline()[:2] != "\\x":
663 f.seek(0, 0)
664 return f
665 f.close()
666 raise NotImplementedError("Wow, binary file")
667
668
669def fromtextfile(fname, delimiter=None, commentchar='#', missingchar='',

Callers 1

fromtextfileFunction · 0.85

Calls 3

openFunction · 0.85
seekMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected