code: def fromtextfile(
      fname,
      delimitor=None,
      commentchar="#",
      missingchar="",
      varnames=None,
      vartypes=None,
  ):
      """
      Creates a mrecarray from data stored in the file `filename`.
  
      Parameters
      ----------
      fname : {file name/handle}
          Handle of an opened file.
      delimitor : {None, string}, optional
          Alphanumeric character used to separate columns in the file.
          If None, any (group of) white spacestring(s) will be used.
      commentchar : {'#', string}, optional
          Alphanumeric character used to mark the start of a comment.
      missingchar : {'', string}, optional
          String indicating missing data, and used to create the masks.
      varnames : {None, sequence}, optional
          Sequence of the variable names. If None, a list will be created from
          the first non empty line of the file.
      vartypes : {None, sequence}, optional
          Sequence of the variables dtypes. If None, it will be estimated from
          the first non-commented line.
  
  
      Ultra simple: the varnames are in the header, one line"""
      # Try to open the file.
      ftext = openfile(fname)
  
      # Get the first non-empty line as the varnames
      while True:
          line = ftext.readline()
          firstline = line[: line.find(commentchar)].strip()
          _varnames = firstline.split(delimitor)
          if len(_varnames) > 1:
              break
      if varnames is None:
          varnames = _varnames
  
      # Get the data.
      _variables = masked_array(
          [
              line.strip().split(delimitor)
              for line in ftext
              if line[0] != commentchar and len(line) > 1
          ]
      )
      (_, nfields) = _variables.shape
      ftext.close()
  
      # Try to guess the dtype.
      if vartypes is None:
          vartypes = _guessvartypes(_variables[0])
      else:
          vartypes = [np.dtype(v) for v in vartypes]
          if len(vartypes) != nfields:
              msg = "Attempting to %i dtypes for %i fields!"
              msg += " Reverting to default."
              warnings.warn(
                  msg % (len(vartypes), nfields), stacklevel=2
              )
              vartypes = _guessvartypes(_variables[0])
  
      # Construct the descriptor.
      mdescr = [(n, f) for (n, f) in zip(varnames, vartypes)]
      mfillv = [ma.default_fill_value(f) for f in vartypes]
  
      # Get the data and the mask.
      # We just need a list of masked_arrays. It's easier to create it like that:
      _mask = _variables.T == missingchar
      _datalist = [
          masked_array(a, mask=m, dtype=t, fill_value=f)
          for (a, m, t, f) in zip(_variables.T, _mask, vartypes, mfillv)
      ]
  
      return fromarrays(_datalist, dtype=mdescr)
  
imports: from __future__ import division, absolute_import, print_function
  import sys
  import warnings
  import numpy
  import numpy.core.numerictypes
  from numpy.compat import basestring
  from numpy import bool_, dtype, ndarray, recarray, array
  from numpy.core.records import fromarrays, fromrecords
  import numpy.ma
  from numpy.ma import MAError, MaskedArray, masked, nomask, masked_array, getdata, getmaskarray, filled
label_desc: Use image node_id 8 for calling a global function with example usage: fromtextfile(fname, delimitor, commentchar, missingchar, varnames, vartypes) and returns: fromarrays