6 ms·
Select, put and delete data from JSON, TOML, YAML, XML and CSV files
- nyellin 5y ago[flagged]
- mkroman 5y agoI think I prefer yq's[1] syntax for manipulating and updating fields. Combined with yj[2] you can also get TOML and HCL support, but not CSV. It's certainly not because there's a lack of these tools :p [1]: https://github.com/mikefarah/yq https://github.com/mikefarah/yq [2]: https://github.com/sclevine/yj https://github.com/sclevine/yj
- RodgerTheGreat 5y agoThe "delete" example on the readme is a bit odd, since it seems to suggest that you need to specify the value to delete as well as the path. The equivalent in the documentation does not have this problem.
- scoopertrooper 5y agoLooks to be a mistake in the readme. The example in the docs doesn't have value being passed in. > echo '{"name": "Tom"}' | dasel -p json '.name' https://daseldocs.tomwright.me/usage/delete https://daseldocs.tomwright.me/usage/delete
- Novalty93 5y agoCan confirm this was a mistake I made when mass-compiling the docs
- username3 5y agoCan this or anything else flatten arrays of JSON objects to CSV?
- TAForObvReasons 5y agohttps://github.com/stedolan/jq https://github.com/stedolan/jq can manipulate arrays of objects and format as CSV
- lichtenberger 5y agoOf course you can do it with http://brackit.io http://brackit.io. What exactly is the "transformation" you envision?
- lichtenberger 5y agoSomething like this (very simplified): let $array := [{"foo":0,"bar":"tztz"},{"foo":"hello","bar":null},{"foo":true,"bar":"yes"}] let $value := for $object in $array return let $fields := bit:fields($object) let $len := bit:len($fields) for $field at $pos in $fields return if ($pos < $len) then ( $object=>$field || "," ) else ( $object=>$field || "\n" ) return string-join($value,"") will output: 0,tztz hello,null true,yes
- lichtenberger 5y agoOf course you can simply create a module with something like the above snippet as a function for reuse. Or I can add a built-in function for flattening like this or as in pandas.
- kbrazil 5y agoYou could do something like this in pure python without the json loading boilerplate with jello[0]. An interactive TUI for jello called jellex[1} is also available. (I am the author) [0] https://github.com/kellyjonbrazil/jello https://github.com/kellyjonbrazil/jello [1] https://github.com/kellyjonbrazil/jellex https://github.com/kellyjonbrazil/jellex
- lichtenberger 5y ago
- AtlasBarfed 5y agoI remember looking through XPath and wondering why no one had converted as much of it as possible to a generic path language for any tree-based data format, which JSON, TOML, YAML, and XML are. XPath was the best of the XML standards. Well, it helps that the language wasn't xml unlike XSLT and others.
- lichtenberger 5y agoRegarding XQuery we just added JSON querying on top in Brackit[1] / SirixDB[2]. Brackit is a retargetable query compiler and does a lot of optimizations at compile time as for instance optimizing joins and aggregations. It is useable as an in-memory processor or as a query processor of a database system. The Ph.D. thesis of Sebastian: Separating Key Concerns in Query Processing - Set Orientation, Physical Data Independence, and Parallelism http://wwwlgis.informatik.uni-kl.de/cms/fileadmin/publications/2013/Dissertation-Baechle.pdf http://wwwlgis.informatik.uni-kl.de/cms/fileadmin/publicatio... [1] http://brackit.io http://brackit.io [2] https://sirix.io https://sirix.io
- HWR_14 5y agoXPath was a great system. However I feel like most of the features required existing XSLTs to support them.
- barakplasma 5y agoReminds me of https://github.com/johnkerl/miller https://github.com/johnkerl/miller which is also a go based tool cloning features from tools like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and tabular JSON
- lichtenberger 5y agoIt is nice, but I wonder if it's also a full-fledged query compiler? Also IMHO modules with user-defined (higher order?) functions are a big plus of a query language.
- ratrocket 5y agoI'm a big fan of miller (mlr) -- it's the tool I landed on when I needed to "graduate" from awk to look at CSV data. But when I read "go based" in your comment, I thought "nope, it's written in C". But no! It was ported to go -- very interesting! The developer wrote a comprehensive document explaining the rationale behind the porting that answered all my questions and a lot more: https://github.com/johnkerl/miller/blob/main/README-go-port.md https://github.com/johnkerl/miller/blob/main/README-go-port..... Thought other miller/mlr fans (that don't follow its development) might find this interesting as well. (The dasel tool looks very cool, too -- looks like a good complement to mlr and similar tools!)
- tpetry 5y agoThat's a fascinating concept. Is there anything similar for INI? Such a tool for ini could help in automatically changing configuration files for software which is most often configured by ini files.
- theluketowers 5y agoNot a generic tool as such, but Winter CMS has a INI parser / renderer built into the core: https://wintercms.com/docs/services/parser#ini-parser https://wintercms.com/docs/services/parser#ini-parser
- emmanueloga_ 5y agoI haven't used it but augeas seems to have support for ini files [1]. 1: https://augeas.net/docs/references/1.4.0/lenses/files/inifile-aug.html https://augeas.net/docs/references/1.4.0/lenses/files/inifil...
- Novalty93 5y agoHey, author of dasel here. I have an issue open to add INI support - just haven't gotten round to it yet. Life has been busy!
- deleted 5y ago[deleted]