docs: def magic_write(ofile, Recs, file_type):
      """
      Parameters
      _________
      ofile : path to output file
      Recs : list of dictionaries in MagIC format
      file_type : MagIC table type (e.g., specimens)
  
      Return :
      [True,False] : True if successful
      ofile : same as input
  
      Effects :
          writes a MagIC formatted file from Recs
  
      """
      if len(Recs) < 1:
          print('No records to write to file {}'.format(ofile))
          return False, ""
      if os.path.split(ofile)[0] != "" and not os.path.isdir(os.path.split(ofile)[0]):
          os.mkdir(os.path.split(ofile)[0])
      pmag_out = open(ofile, 'w+', errors="backslashreplace")
      outstring = "tab \t" + file_type
      outstring = outstring.strip("\n").strip(
          "\r") + "\n"  # make sure it's clean for Windows
      pmag_out.write(outstring)
      keystring = ""
      keylist = []
      for key in list(Recs[0].keys()):
          keylist.append(key)
      keylist.sort()
      for key in keylist:
          keystring = keystring + '\t' + key.strip()
      keystring = keystring + '\n'
      pmag_out.write(keystring[1:])
      for Rec in Recs:
          outstring = ""
          for key in keylist:
              try:
                  outstring = outstring + '\t' + str(Rec[key]).strip()
              except KeyError:
                  if 'er_specimen_name' in list(Rec.keys()):
                      print(Rec['er_specimen_name'])
                  elif 'specimen' in list(Rec.keys()):
                      print(Rec['specimen'])
                  elif 'er_specimen_names' in list(Rec.keys()):
                      print('specimen names:', Rec['er_specimen_names'])
                  print("No data for %s" % key)
                  # just skip it:
                  outstring = outstring + "\t"
                  # raw_input()
          outstring = outstring + '\n'
          pmag_out.write(outstring[1:])
      pmag_out.close()
      print(len(Recs), ' records written to file ', ofile)
      return True, ofile