Live data from Hacker News

Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

github.com

31–40 of 109 posts

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#31
post #12

While I get what they mean by "tabular JSON", that's a bit of a misnomer.

I was wondering what they meant by that term as well. Does every JSON document in the array have to have the exact same structure (including the ordering of key-value pairs)? What happens if row #1000 introduces a new key-value pair not seen before? What if the value for a key is an array?

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#32
post #26
post #23

Earlier quoted context omitted.

The whole point of UNIX userland is to not have to write a custom program for every simple case that just needs recombining some existing basic programs in a pipeline...

> simple case that's just it though, the last example is not a simple case, hence why the last example is awkward by the commenters own admission. command line tools are fine, but you need to know when to set the hammer down and pick up the chainsaw.

To me the last example is still simple. When I encounter this in the wild, I don't really care about preserving the header.

  tail -n +2 example.csv | sort -r -k4 -t','
Or more often, I just do this and ignore the header

  sort -r -k4 -t',' example.csv
Keeping the header feels awkward, but using `sort` to reverse sort by a specific column is still quicker to type and execute (for me) than writing a program.

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#33
post #10

Even without aliases, I still prefer PowerShell on Windows. Once you've turned the text into an object, you can pipeline it to hell. Get-Content .\example.csv | ConvertFrom-Csv | Where-Object -Property color -eq red

No thank you. I appreciate the power, speed, simplicity and flexibility of UNIX/GNU style text tools. I-Also-Don't-Want-To-Be-Locked-Into-This-Ridiculous-Syntax-Nightmare.

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#34
post #21
post #9

Great tool. BUT, leaks memory like crazy. Despite documentation stating the verbs are fully streaming. > Fully streaming verbs > These don't retain any state from one record to the next. They are memory-friendly, and they don't wait for end of input to produce their output. https://miller.readthedocs.io/en/6.7.0/streaming-and-memory/...

> BUT, leaks memory like crazy. Huh? a) Isn't it written in Golang, which has a GC? Does it do custom buffer based management? b) Isn't it supposed to be run on a file and get some output - as opposed to an interactice session? Why would it matter if it leaks, then, and how could it leak, as the memory is returned to the OS when it ends?

It's indeed written in Go now, which indeed has GC, and ultimately all memory is freed ... but there are indeed some issues around intermediate retention of memory, taking more memory than one would have expected.

Some gains were made on https://github.com/johnkerl/miller/pull/1133 and https://github.com/johnkerl/miller/pull/1132

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#35
post #21

Earlier quoted context omitted.

> BUT, leaks memory like crazy. Huh? a) Isn't it written in Golang, which has a GC? Does it do custom buffer based management? b) Isn't it supposed to be run on a file and get some output - as opposed to an interactice session? Why would it matter if it leaks, then, and how could it leak, as the memory is returned to the OS when it ends?

It's indeed written in Go now, which indeed has GC, and ultimately all memory is freed ... but there are indeed some issues around intermediate retention of memory, taking more memory than one would have expected. Some gains were made on https://github.com/johnkerl/miller/pull/1133 and https://github.com/johnkerl/miller/pull/1132

See also https://github.com/johnkerl/miller/issues/1119

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#36
post #27

How is it better that SQL for these tasks on tabular data? That's the first question I have after reading the title. Haven't read the article. Edited the first sentence. Originally it was "Why it is not called SQL if works on tabular data?". My point, if one wants cat, sort, sed, join on tabular data, SOL is exactly that. Awk is too powerful, not sure about it.

> How is it better that SQL for these tasks on tabular data? It has far better handling of a CSV/TSV file on the command line directly and is compasable in shell pipelines. > My point, if one wants cat, sort, sed, join on tabular data, SOL is exactly that. SQL is a language for data in the form of tables in relational databases. While it can do sorting or joining or some changes, it is meant for a different domain th…

DuckDB is actually pretty good at this kind of thing.

Doesn't need to load anything to DB

Can be used in shell

Can read from stdin and write to stdout

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#39
Looks cool! It'd help to have some more full examples (including output) of what some common use-cases do in the README. After looking through this, I'm still scratching my head trying to think of what problem this could solve in my own practice, and I work with a lot of csv files daily

Re: Miller: Like Awk, sed, cut, join, and sort for CSV, TSV, and tabular JSON

#40

Discussion of a similar tool last month: yq: command-line YAML, JSON, XML, CSV and properties processor https://news.ycombinator.com/item?id=34656022 Also mentions gojq, Benthos, xsv, Damsel, a 2nd yq, htmlq, cfn-flip, csvq, zq, and zsv.

I have made a repository cataloguing tools like this: https://github.com/dbohdan/structured-text-tools.
Post reply on HN