MCPcopy Index your code
hub / github.com/numpy/numpy / openfile

Function openfile

numpy/ma/mrecords.py:616–633  ·  view source on GitHub ↗

Opens the file handle of file `fname`.

(fname)

Source from the content-addressed store, hash-verified

614
615
616def openfile(fname):
617 """
618 Opens the file handle of file `fname`.
619
620 """
621 # A file handle
622 if hasattr(fname, 'readline'):
623 return fname
624 # Try to open the file and guess its type
625 try:
626 f = open(fname)
627 except FileNotFoundError as e:
628 raise FileNotFoundError(f"No such file: '{fname}'") from e
629 if f.readline()[:2] != "\\x":
630 f.seek(0, 0)
631 return f
632 f.close()
633 raise NotImplementedError("Wow, binary file")
634
635
636def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…