### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- datamodel - easy to use general data model »

# spacepy.datamodel.toJSONheadedASCII

`spacepy.datamodel.``toJSONheadedASCII`(fname, insd, metadata=None, depend0=None, order=None, **kwargs)

  Write JSON-headed ASCII file of data with metadata from SpaceData object

  Parameters: | fname : str Filename to write to (can also use a file-like object) None can be given in conjunction with the returnString keyword to skip writing output insd : spacepy.datamodel.SpaceData SpaceData with associated attributes and variables in dmarrays
  Returns: | None :
  Other Parameters:
  | depend0 : str (optional) variable name to use to indicate parameter on which other data depend (e.g. Time) order : list (optional) list of key names in order of start column in output JSON file metadata: str or file-like (optional) : filename with JSON header to use (or file-like with JSON metadata) delimiter: str : delimiter to use in ASCII output (default is whitespace), for tab, use ‘ ‘

  Examples

      >>> import spacepy.datamodel as dm
      >>> data = dm.SpaceData()
      >>> data.attrs['Global'] = 'A global attribute'
      >>> data['Var1'] = dm.dmarray([1,2,3,4,5], attrs={'Local1': 'A local attribute'})
      >>> data['Var2'] = dm.dmarray([[8,9],[9,1],[3,4],[8,9],[7,8]])
      >>> data['MVar'] = dm.dmarray([7.8], attrs={'Note': 'Metadata'})
      >>> dm.toJSONheadedASCII('outFile.txt', data, depend0='Var1', order=['Var1'])
      #Note that not all field names are required, those not given will be listed
      #alphabetically after those that are specified

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- datamodel - easy to use general data model »