code: def export_trials_data(args):
      
      nni_config = Config(get_config_filename(args))
      rest_port = nni_config.get_config('restServerPort')
      rest_pid = nni_config.get_config('restServerPid')
      if not detect_process(rest_pid):
          print_error('Experiment is not running...')
          return
      running, response = check_rest_server_quick(rest_port)
      if running:
          response = rest_get(trial_jobs_url(rest_port), 20)
          if response is not None and check_response(response):
              content = json.loads(response.text)
              # dframe = pd.DataFrame.from_records([parse_trial_data(t_data) for t_data in content])
              # dframe.to_csv(args.csv_path, sep='\t')
              records = parse_trial_data(content)
              if args.type == 'json':
                  json_records = []
                  for trial in records:
                      value = trial.pop('reward', None)
                      trial_id =  trial.pop('id', None)
                      json_records.append({'parameter': trial, 'value': value, 'id': trial_id})
              with open(args.path, 'w') as file:
                  if args.type == 'csv':
                      writer = csv.DictWriter(file, set.union(*[set(r.keys()) for r in records]))
                      writer.writeheader()
                      writer.writerows(records)
                  else:
                      json.dump(json_records, file)
          else:
              print_error('Export failed...')
      else:
          print_error('Restful server is not Running')
docs: export experiment metadata to csv