code: def save_file(self, filepath, save_as=None, keep_orig=False, **kwargs):
          
          df = self._models[filepath].dataFrame()
          kwargs['index'] = kwargs.get('index', False)
  
          if save_as is not None:
              to_path = save_as
          else:
              to_path = filepath
  
          ext = os.path.splitext(to_path)[1].lower()
  
          if ext == ".xlsx":
              kwargs.pop('sep', None)
              df.to_excel(to_path, **kwargs)
  
          elif ext in ['.csv','.txt']:
              df.to_csv(to_path, **kwargs)
  
          else:
              raise NotImplementedError("Cannot save file of type {}".format(ext))
  
          if save_as is not None:
              if  keep_orig is False:
                  # Re-purpose the original model
                  # Todo - capture the DataFrameModelManager._updates too
                  model = self._models.pop(filepath)
                  model._filePath = to_path
              else:
                  # Create a new model.
                  model = DataFrameModel()
                  model.setDataFrame(df, copyDataFrame=True, filePath=to_path)
  
              self._models[to_path] = model
docs: Saves a DataFrameModel to a file.
  
          :param filepath: (str)
              The filepath of the DataFrameModel to save.
          :param save_as: (str, default None)
              The new filepath to save as.
          :param keep_orig: (bool, default False)
              True keeps the original filepath/DataFrameModel if save_as is specified.
          :param kwargs:
              pandas.DataFrame.to_excel(**kwargs) if .xlsx
              pandas.DataFrame.to_csv(**kwargs) otherwise.
          :return: None