...
Excerpt | ||
---|---|---|
| ||
For the moment there is no simple way of knowing what the type of a key value is. However, the library provides a function that can be used to find out what the native type of a key value is |
Step-by-step guide
For the moment there is no simple way of knowing what the type of a key value is. However, the library provides a function that can be used to find out what the native type of a key value is.
The function, available only in the C API, is called 'grib_get_native_type'. Possible key value types are It returns an integer which can be checked against the following : undefined, long, double, string, bytes, section, label or missingmacros:
CODES_TYPE_UNDEFINED
CODES_TYPE_LONG
CODES_TYPE_DOUBLE
CODES_TYPE_STRING
CODES_TYPE_BYTES
CODES_TYPE_SECTION
CODES_TYPE_LABEL
CODES_TYPE_MISSING
As of version 2.14.0, one can use the grib_dump tool with the "-p" option to dump a given key and query its type with the "-t" option.
E.g.
Code Block | ||
---|---|---|
| ||
% grib_dump -t -p identifier my.grib
# type ascii (str)
#-READ ONLY- identifier = GRIB;
% grib_dump -t -p referenceValue my.grib
# type ieeefloat (double)
#-READ ONLY- referenceValue = 45.67; |
Here you can see that the key "identifier" is of type string and "referenceValue" is a double.
Related articles
Content by Label | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...