File: test_keysiterator.py

package info (click to toggle)
eccodes 2.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 480,184 kB
  • sloc: ansic: 163,815; makefile: 21,266; sh: 8,507; python: 6,026; f90: 5,762; perl: 2,891; yacc: 818; lex: 356; cpp: 305; fortran: 116; awk: 66
file content (31 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python

from __future__ import print_function
import sys
from .gribapi import *

infile = sys.argv[1]
fid = open(infile,"r")
count = grib_count_in_file(fid)

for i in range(count):
    gid = grib_new_from_file(fid)
    iterid = grib_keys_iterator_new(gid)

#    grib_skip_computed(iterid)
#    grib_skip_coded(iterid)
#    grib_skip_edition_specific(iterid)
#    grib_skip_duplicated(iterid)
#    grib_skip_read_only(iterid)
#    grib_skip_function(iterid)

    while grib_keys_iterator_next(iterid):
        keyname = grib_keys_iterator_get_name(iterid)
        keyval = grib_get_string(iterid,keyname)
        keytype = grib_get_native_type(gid,keyname)
        print ("%s = %s (%s)" % (keyname,keyval,str(keytype)))

    grib_keys_iterator_delete(iterid)
    grib_release(gid)

fid.close()