./
pp_struct_unravel.pro
Routines
top source pp_struct_unravel
result = pp_struct_unravel(str [, testonly=testonly])
This function is used to obtain a flat structure from a nested structure.
Its output is useful as an input to write_csv (and write_csv_pp
).
Return value
Produces a flat structure from a nested structure. If the input variable str
does
not have nested structures, an identical copy is returned.
Parameters
- str in required
The structure to be flattened. See example below.
Keywords
- testonly in optional default=0
If set, instead of returning a copy of the structure, only a test is performed, to determine whether the given variable is a nested structure. This is useful when the structure is large: upon determining that the structure is not nested, the user might decide to use the original structure, instead of the output of pp_struct_unravel (which would just be a copy of the original structure).
Examples
Define a nested structure and then flatten it:
str={a:1,b:[2,3],c:{d:'e',f:2.6},g:-1}
help,str
;** Structure <eda88578>, 4 tags, length=40, data length=28, refs=1:
;A INT 1
;B INT Array[2]
;C STRUCT -> <Anonymous> Array[1]
;G INT -1
help,pp_struct_unravel(str)
;** Structure <ec63eeb8>, 5 tags, length=32, data length=28, refs=1:
;A INT 1
;B INT Array[2]
;C_D STRING 'e'
;C_F FLOAT 2.60000
;G INT -1
Author information
- Author:
Paulo Penteado (http://www.ppenteado.net), Feb/2013
Statistics
Lines: | 24 lines |
Cyclomatic complexity: | 11 |
Modified cyclomatic complexity: | 11 |
File attributes
Modification date: | Wed Jun 29 22:15:28 2016 |
Lines: | 24 |
Docformat: | rst rst |