code: def from_cnv(fname):
      
      f = _read_file(fname)
      metadata = _parse_seabird(f.readlines(), ftype="cnv")
  
      f.seek(0)
      df = pd.read_fwf(
          f,
          header=None,
          index_col=None,
          names=metadata["names"],
          skiprows=metadata["skiprows"],
          delim_whitespace=True,
          widths=[11] * len(metadata["names"]),
      )
      f.close()
  
      key_set = False
      prkeys = ["prDM", "prdM", "pr"]
      for prkey in prkeys:
          try:
              df.set_index(prkey, drop=True, inplace=True)
              key_set = True
          except KeyError:
              continue
      if not key_set:
          raise KeyError(
              f"Could not find pressure field (supported names are {prkeys})."
          )
      df.index.name = "Pressure [dbar]"
  
      name = _basename(fname)[1]
  
      dtypes = {"bpos": int, "pumps": bool, "flag": bool}
      for column in df.columns:
          if column in dtypes:
              df[column] = df[column].astype(dtypes[column])
          else:
              try:
                  df[column] = df[column].astype(float)
              except ValueError:
                  warnings.warn("Could not convert %s to float." % column)
  
      metadata["name"] = str(name)
      setattr(df, "_metadata", metadata)
      return df
docs: DataFrame constructor to open Seabird CTD CNV-ASCII format.
  
      Examples
      --------
      >>> from pathlib import Path
      >>> import ctd
      >>> data_path = Path(__file__).parents[1].joinpath("tests", "data")
      >>> cast = ctd.from_cnv(data_path.joinpath('CTD_big.cnv.bz2'))
      >>> downcast, upcast = cast.split()
      >>> ax = downcast['t090C'].plot_cast()