# spacepy.datamodel.flatten

spacepy.datamodel.flatten(dobj)

  Collapse datamodel to one level deep

  See also

  `unflatten`
  `SpaceData.flatten`

  Examples

      >>> import spacepy.datamodel as dm
      >>> import spacepy.toolbox as tb
      >>> a = dm.SpaceData()
      >>> a['1'] = dm.SpaceData(dog = 5, pig = dm.SpaceData(fish=dm.SpaceData(a='carp', b='perch')))
      >>> a['4'] = dm.SpaceData(cat = 'kitty')
      >>> a['5'] = 4
      >>> a.tree()
      +
      |____1
           |____dog
           |____pig
                |____fish
                     |____a
                     |____b
      |____4
           |____cat
      |____5

      >>> b = dm.flatten(a)
      >>> b.tree()
      +
      |____1<--dog
      |____1<--pig<--fish<--a
      |____1<--pig<--fish<--b
      |____4<--cat
      |____5

      >>> a.flatten()
      >>> a.tree()
      +
      |____1<--dog
      |____1<--pig<--fish<--a
      |____1<--pig<--fish<--b
      |____4<--cat
      |____5