def save_tsv_table(filename, results):
  """Save dict of expt() outputs in a TSV file."""
  filename = FLAGS.table_tag + filename
  tf.logging.info('writing to %r' % filename)
  with tf.io.gfile.GFile(filename, 'w') as fp:
    cols = None
    for k, d in sorted(results.items()):
      if cols is None:
        d_keys = sorted(d.keys())
        cols = ['key'] + d_keys
        fp.write('\t'.join(cols) + '\n')
      fp.write('\t'.join([repr(k)] + [repr(d[dk]) for dk in d_keys]) + '\n')
Save dict of expt() outputs in a TSV file.
language/nql/demos/gridworld_scaling/scaling_eval.py