def write_magic_file(self, custom_name=None, dir_path=".",
                         append=False, multi_type=False, df=None):
        """
        Write self.df out to tab-delimited file.
        By default will use standard MagIC filenames (specimens.txt, etc.),
        or you can provide a custom_name to write to instead.
        By default will write to custom_name if custom_name is a full path,
        or will write to dir_path + custom_name if custom_name
        is not a full path.

        Parameters
        ----------
        self : MagIC DataFrame
        custom_name : str
            custom file name
        dir_path : str
            dir_path (used if custom_name is not a full path), default "."
        append : bool
            append to existing file, default False
        multi_type : bool
            for creating upload file

        Return
        --------
        fname : str
            output file name
        """
        # don't let custom name start with "./"
        if custom_name:
            if custom_name.startswith('.'):
                custom_name = os.path.split(custom_name)[1]
        # put columns in logical order (by group)
        self.sort_dataframe_cols()
        # if indexing column was put in, remove it
        if "num" in self.df.columns:
            self.df = self.df.drop("num", axis=1)
        #
        # make sure name is a string
        name = self.get_singular_and_plural_dtype(self.dtype)[0]
        if name in self.df.columns:
            self.df[name] = self.df[name].astype(str)
        #
        if df is None:
            df = self.df
        # get full file path
        dir_path = os.path.realpath(dir_path)
        if custom_name:
            fname = pmag.resolve_file_name(custom_name, dir_path) # os.path.join(dir_path, custom_name)
        elif self.magic_file:
            fname = pmag.resolve_file_name(self.magic_file, dir_path)
        else:
            fname = os.path.join(dir_path, self.dtype + ".txt")
        # see if there's any data
        if not len(df):
            print('-W- No data to write to {}'.format(fname))
            return False
        # add to existing file
        if append:
            print('-I- appending {} data to {}'.format(self.dtype, fname))
            mode = "a"
        # overwrite existing file
        elif os.path.exists(fname):
            print('-I- overwriting {}'.format(fname))
            mode = "w"
        # or create new file
        else:
            print('-I- writing {} records to {}'.format(self.dtype, fname))
            mode = "w"
        f = open(fname, mode)
        if append:
            header = False
            if multi_type:
                header = True
                f.write('tab\t{}\n'.format(self.dtype))
            f.flush()
            df.to_csv(f, sep="\t", header=header, index=False, mode='a')
        else:
            f.write('tab\t{}\n'.format(self.dtype))
            f.flush()
            df.to_csv(f, sep="\t", header=True, index=False, mode='a')
        print('-I- {} records written to {} file'.format(len(df), self.dtype))
        f.close()
        return fname
Write self.df out to tab-delimited file.
        By default will use standard MagIC filenames (specimens.txt, etc.),
        or you can provide a custom_name to write to instead.
        By default will write to custom_name if custom_name is a full path,
        or will write to dir_path + custom_name if custom_name
        is not a full path.

        Parameters
        ----------
        self : MagIC DataFrame
        custom_name : str
            custom file name
        dir_path : str
            dir_path (used if custom_name is not a full path), default "."
        append : bool
            append to existing file, default False
        multi_type : bool
            for creating upload file

        Return
        --------
        fname : str
            output file name