STAG-FLATTEN(1)

πŸ“¦
version 0.14 Β· 3 versions
, in fedora 43

✨ NAME ✨

stag-flatten β€” turns stag data into a flat table. that's it, that's the whole job, and it does it gorgeously πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

stag-flatten -c name -c person/name dept MyFile.xml

like. look at her. one line and she's already slaying ✨


πŸ’– DESCRIPTION πŸ’–

okay so bestie, here's the tea β˜• β€” stag-flatten reads in a file that's in stag format, and then it 'flattens' it into a tab-delimited table format. it's giving "nested tree, but make it a spreadsheet."

so say you roll up with this data:

(company
 (dept
  (name "special-operations")
  (person
   (name "james-bond"))
  (person
   (name "fred"))))

the command up there in the synopsis will hand you back a two column table, no cap:

special-operations      james-bond
special-operations      fred

see how it works? the dept name gets repeated for every person inside it. iconic behaviour, honestly 🫢

⚠️ and here's the part you actually need to remember: if there are multiple values for the columns within the node, then the cartesian product will be calculated. not me doing math in public 😭 but that's literally what happens, so don't be surprised when your row count explodes.

πŸ“‹ USAGE πŸ“‹

stag-flatten [-p PARSER] [-c COLS] [-c COLS] NODE <file>

🫢 ARGUMENTS 🫢

  • -p|parser FORMAT β€” FORMAT is one of xml, sxpr or itext. and xml assumed as default, so if your file is xml you can just vibe and not mention it 🌸
  • -c|column COL1,COL2,COL3,.. β€” the name of the columns/elements to write out. and bestie you've got two ways to feed her: either specify it with multiple -c arguments, or hand over a comma-seperated (no spaces) list of column (terminal node) names after a single -c. pick your fighter, both eat πŸ’…
πŸ™ˆ fr fr, watch the spaces. it says no spaces and it means no spaces.
  • -n|nest β€” if set, then the output will be a compress repeating values into the same row; every single cell in the table will be enclosed by {}, and will contain a comma-delimited set of values. so instead of a million rows you get one row with lil curly-brace bundles. obsessed πŸŽ€

🌈 SEE ALSO 🌈

  • Data::Stag β€” go look at the mothership, she's right there πŸ’œ

and that's the whole page, bestie!! this one's running on perl v5.42.0, dated 2025-07-25 β€” user contributed Perl documentation, section 1 of the manual, and yes she ate and left no crumbs πŸ¦‹βœ¨

πŸ“¦ where this page comes from