docs: def combine_magic(filenames, outfile='measurements.txt', data_model=3, magic_table='measurements',
                    dir_path=".", input_dir_path=""):
      """
      Takes a list of magic-formatted files, concatenates them, and creates a
      single file. Returns output filename if the operation was successful.
  
      Parameters
      -----------
      filenames : list of MagIC formatted files
      outfile : name of output file [e.g., measurements.txt]
      data_model : data model number (2.5 or 3), default 3
      magic_table : name of magic table, default 'measurements'
      dir_path : str
          output directory, default "."
      input_dir_path : str
          input file directory (if different from dir_path), default ""
  
  
      Returns
      ----------
      outfile name if success, False if failure
      """
      input_dir_path, output_dir_path = pmag.fix_directories(input_dir_path, dir_path)
      if float(data_model) == 3.0:
          outfile = pmag.resolve_file_name(outfile, output_dir_path)
          output_dir_path, file_name = os.path.split(outfile)
          con = cb.Contribution(output_dir_path, read_tables=[])
          # make sure files actually exist
          filenames = [pmag.resolve_file_name(f, input_dir_path) for f in filenames]
          #filenames = [os.path.realpath(f) for f in filenames]
          filenames = [f for f in filenames if os.path.exists(f)]
          if not filenames:
              print("You have provided no valid file paths, so nothing will be combined".format(
                  magic_table))
              return False
          # figure out file type from first of files to join
          with open(filenames[0]) as f:
              file_type = f.readline().split()[1]
          if file_type in ['er_specimens', 'er_samples', 'er_sites',
                           'er_locations', 'er_ages', 'pmag_specimens',
                           'pmag_samples', 'pmag_sites', 'pmag_results',
                           'magic_measurements', 'rmag_anisotropy',
                           'rmag_results', 'rmag_specimens']:
              print(
                  '-W- You are working in MagIC 3 but have provided a MagIC 2.5 file: {}'.format(file_type))
              return False
          if file_type not in con.table_names:
              file_type = magic_table
          infiles = [pd.read_csv(infile, sep='\t', header=1)
                     for infile in filenames]
          df = pd.concat(infiles, ignore_index=True, sort=True)
          # drop any fully duplicated rows
          df.drop_duplicates(inplace=True)
          con.add_magic_table(dtype=file_type, df=df)
          # drop any mostly empty rows IF they have duplicate index
          parent, child = con.get_parent_and_child(file_type)
          ignore_cols = [col[:-1] for col in [file_type, parent] if col]
          ignore_cols.extend(['software_packages', 'citations'])
          con.tables[file_type].drop_duplicate_rows(ignore_cols)
          # correctly handle measurements.sequence column
          if 'sequence' in con.tables[file_type].df:
              con.tables[file_type].df['sequence'] = range(1, len(con.tables[file_type].df) + 1)
          # write table to file, use custom name
          res = con.write_table_to_file(file_type, custom_name=file_name)
          return res
      else:
          datasets = []
          if not filenames:
              print("You must provide at least one file")
              return False
          for infile in filenames:
              if not os.path.isfile(infile):
                  print("{} is not a valid file name".format(infile))
                  return False
              try:
                  dataset, file_type = pmag.magic_read(infile)
              except IndexError:
                  print('-W- Could not get records from {}'.format(infile))
                  print('    Skipping...')
                  continue
              print("File ", infile, " read in with ", len(dataset), " records")
              for rec in dataset:
                  datasets.append(rec)
  
          Recs, keys = pmag.fillkeys(datasets)
          if Recs:
              pmag.magic_write(outfile, Recs, file_type)
              print("All records stored in ", outfile)
              return outfile
          print("No file could be created")
          return False