Questions tagged [glom]

glom is a Python module for declaratively accessing and transforming data

Features

  • Path-based access for nested structures
  • Declarative data transformation using lightweight, Pythonic specifications
  • Readable, meaningful error messages
  • Built-in data exploration and debugging features
  • Command-line interface (CLI) available

Links

33 questions
0
votes
1 answer

Is there an easy way to use glom to get an unknown key from a dictionary?

Is there an easy way to use glom to get an unknown key from a dictionary? the ??? represents random data that I am trying to capture from an API book = {"???":[{ "globalIdenity":208565940},{"globalIdenity":228049454}]} spec = …
Scott
  • 1
0
votes
0 answers

How to say "collect all of them" in glom?

What are the glom tricks to be able to say "collect all of them". An example of what I mean: What would the glom way of extracting {'a': [[11], [22, 22]], 'b': [[33, 33, 33], [44, 44, 44, 44]]} from target = { 'a': { 1: { …
thorwhalen
  • 1,920
  • 14
  • 26
0
votes
1 answer

Slice level with glom

I have a nested structure like target = \ {'A1': {'B1': 'a1b1', 'B2': 'a1b2' } {'A2': {'B1': 'a2b1', 'B2': 'a2b2' } } how can I easily find all the items which have 'B2' in the second level (pandas terminology) i.e. ['a1b2',…
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141
1 2
3