code: def to_file(self, path, format='infer', skip_nulls=True):
          
          format = _infer_format(path, format=format)
          data = getattr(self, 'to_' + format)(skip_nulls=skip_nulls)
          with open(path, mode='w') as f:
              f.write(data)
docs: Write object to a file.
  
          Parameters
          ----------
          path : str
              The path to the file to load.
          format : {'infer', 'json', 'yaml'}, optional
              The file format. By default the format is inferred from the file
              extension.
          skip_nulls : bool, optional
              By default null values are skipped in the output. Set to True to
              output all fields.