KxSystems / hdf5

A library for converting between kdb+ and HDF5 data
https://code.kx.com/q/interfaces
Apache License 2.0
13 stars 8 forks source link

.hdf5.ls change to prevent printing to stdout #35

Closed sshanks-kx closed 2 years ago

sshanks-kx commented 2 years ago

Return details so user in control of whether to print to stdout/parse/etc, rather than printing.

sshanks-kx commented 2 years ago

Now creates a dict (keys 'type','name',value'). When an entry is a group, its value contains a dict (and so on)

the following

{
  Group: kdb_table {
    Dataset: Latitude
    Dataset: Longitude
    Dataset: Name
    Dataset: Pressure
    Dataset: Temperature
  }
}

ends up as

q)a
type | group                                                                 ..
name | `kdb_table                                                            ..
value| `type`name`value!(`dataset`dataset`dataset`dataset`dataset;(`Latitude;..

q)(a`value)[0]
type | dataset         dataset         dataset         dataset         datase..
name | `Latitude       `Longitude      `Name           `Pressure       `Tempe..
value| (`symbol$())!() (`symbol$())!() (`symbol$())!() (`symbol$())!() (`symb..

or for this example

{
  Group: Domain_03 {
    Group: OSBS {
      Group: min_1 {
        Group: boom_1 {
          Dataset: temperature
        }
        Group: boom_2 {
          Dataset: temperature
        }
        Group: boom_3 {
          Dataset: temperature
        }
        Group: boom_5 {
          Dataset: temperature
        }
        Group: tower_top {
          Dataset: temperature
        }
      }
      Group: min_30 {
        Group: boom_1 {
          Dataset: temperature
        }
        Group: boom_2 {
          Dataset: temperature
        }
        Group: boom_3 {
          Dataset: temperature
        }
        Group: boom_5 {
          Dataset: temperature
        }
        Group: tower_top {
          Dataset: temperature
        }
      }
    }
  }
  Group: Domain_10 {
    Group: STER {
      Group: min_1 {
        Group: boom_1 {
          Dataset: temperature
        }
        Group: boom_2 {
          Dataset: temperature
        }
        Group: boom_3 {
          Dataset: temperature
        }
      }
      Group: min_30 {
        Group: boom_1 {
          Dataset: temperature
        }
        Group: boom_2 {
          Dataset: temperature
        }
        Group: boom_3 {
          Dataset: temperature
        }
      }
    }
  }
}

now ends up as

q)a
type | group                                                                 ..
name | `Domain_03                                                            ..
value| `type`name`value!(,`group;,`OSBS;,`type`name`value!(`group`group;(`min..
q)(a`value)[0]
type | group                                                                 ..
name | `OSBS                                                                 ..
value| `type`name`value!(`group`group;(`min_1;`min_30);(`type`name`value!(`gr..
q)((a`value)[0]`value)[0]                    
type | group                                                                 ..
name | `min_1                                                                ..
value| `type`name`value!(`group`group`group`group`group;(`boom_1;`boom_2;`boo..