ITADN
johnkerl/miller
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

什么是 Miller?

Miller 类似于 awk、sed、cut、join 和 sort,适用于 CSV、TSV、JSON、JSON Lines 以及基于位置索引等数据格式。

Miller 能为我做什么?

使用 Miller,你可以使用命名字段而无需计算位置索引,并采用 CSV、TSV、JSON、JSON Lines 以及基于位置索引等熟悉的格式。然后,你可以即时添加作为现有字段函数的新字段、删除字段、排序、进行统计聚合、美化输出等。

cover-art

  • Miller 处理的是键值对数据,而熟悉的 Unix 工具处理的是整数索引字段:如果后者的自然数据结构是数组,那么 Miller 的自然数据结构就是 保持插入顺序的哈希映射。

  • Miller 支持多种数据格式, 包括但不限于熟悉的 CSVTSV 以及 JSON/JSON Lines。 (Miller 也能处理位置索引数据!)

在上面的图片中,你可以看到 Miller 如何拥抱各种数据格式中键值对数据的共同主题。

安装

你很可能会找到为你的系统预构建的 Miller: Ubuntu Ubuntu 16.04 LTS Fedora Debian Gentoo Pro-Linux Arch Linux NetBSD FreeBSD Anaconda Snap Homebrew/MacOSX MacPorts/MacOSX Chocolatey WinGet

操作系统安装命令
Linuxyum install miller
apt-get install miller
snap install miller
Macbrew install miller
port install miller
Windowschoco install miller
winget install Miller.Miller
scoop install main/miller

另请参阅 README-versions.md 以获取完整的软件包版本列表。请注意,长期支持(LtS)版本可能基于较旧的版本。

另请参阅 从源码构建

特性

  • Miller 是多用途的:它适用于数据清洗数据缩减统计报告devops系统 管理日志文件处理格式转换 以及 数据库查询后处理

  • 你可以使用 Miller 来抓取和处理日志文件数据,包括 筛选出相关的子流,然后生成 CSV 格式并将其加载到 全内存/数据框工具中,以进行进一步的统计和/或图形 处理。

  • Miller 补充了数据分析工具,例如 Rpandas 等: 你可以使用 Miller 来清理准备你的数据。虽然你可以完全在 Miller 中执行 基本统计,但其流式数据特性和 单遍算法使你能够缩减非常大的数据集

  • Miller 补充了 SQL 数据库:你可以在客户端对数据进行切片、切块和重新格式化, 以便将其输入或输出数据库。你还可以在需要快速、无需设置的一次性任务时, 获得数据库的一些好处,当你只是 需要紧急查询磁盘文件中的一些数据时。

  • Miller 还超越了经典的 Unix 工具,完全步入我们 现代的无 SQL世界:其基本的记录异构性属性允许 Miller 操作那些具有不同模式(字段名)的记录 交错的数据。

  • Miller 是流式的:大多数操作每次只需在内存中处理一条记录,而不是在产生任何输出之前先摄取所有输入。 对于需要更深层次保留的操作(sorttacstats1), Miller 仅保留所需的数据量。这意味着只要功能上可行, 你就可以处理比系统’s 可用 RAM 更大的文件,并且可以在 tail -f 上下文中使用 Miller。

  • Miller 是管道友好的,并且与 Unix 工具包互操作。

  • Miller 的 I/O 格式包括表格化美观打印按位置索引 (Unix 工具包风格)、CSV、TSV、JSON、JSON Lines 等。

  • Miller 在格式之间进行转换

  • Miller 的处理是格式感知的:例如,CSV sorttac 会将表头行保持在最前面。

  • Miller 具有与 Unix 工具包相当的高性能吞吐量。

  • Miller 使用可移植的现代 Go 编写,具有零运行时依赖。 你可以下载或编译单个二进制文件,scp 它到远程机器上, 并期望它能正常工作。

入门

deepwiki

更多文档链接

社区

GitHub stars Homebrew downloads Conda downloads

All Contributors

构建状态

Multi-platform build status CodeQL status Codespell status 🧪 Snap Builds

从源码构建

  • 首先:
    • cd /where/you/want/to/put/the/source
    • git clone https://github.com/johnkerl/miller
    • cd miller
  • 使用 make
    • 构建:make。这只需几秒钟,并生成 Miller 可执行文件,即 ./mlr(在 Windows 上为 .\mlr.exe)。
    • 运行测试:make check
    • 安装:make install。这将安装可执行文件 /usr/local/bin/mlr 和手册页 /usr/local/share/man/man1/mlr.1(因此你可以执行 man mlr)。
    • 如果你希望安装到 /usr/local 以外的位置,可以在 make install 之前执行 ./configure --prefix=/some/install/path
  • 不使用 make
    • 构建:go build github.com/johnkerl/miller/v6/cmd/mlr
    • 运行测试:go test github.com/johnkerl/miller/v6/pkg/...mlr regtest
    • 安装:go install github.com/johnkerl/miller/v6/cmd/mlr@latest 将安装到 GOPATH/bin/mlr
  • 另请参阅关于 从源代码构建 的文档页面。
  • 有关更多开发者信息,请参阅 README-dev.md

面向开发者

许可证

许可证: BSD2

人们对 Miller 的评价

Contributors ✨

感谢所有帮助让 Miller 变得更好的优秀人士(emoji key):

<td align="center"><a href="https://dsel.net/"><img src="https://avatars.githubusercontent.com/u/921669?v=4?s=50" width="50px;" alt=""/><br /><sub><b>David Selassie</b></sub></a><br /><a href="#ideas-davidselassie" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://www.joelparkerhenderson.com/"><img src="https://avatars.githubusercontent.com/u/27145?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Joel Parker Henderson</b></sub></a><br /><a href="#ideas-joelparkerhenderson" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/divtiply"><img src="https://avatars.githubusercontent.com/u/5359679?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Michel Ace</b></sub></a><br /><a href="#ideas-divtiply" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://fuco1.github.io/sitemap.html"><img src="https://avatars.githubusercontent.com/u/2664959?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Matus Goljer</b></sub></a><br /><a href="#ideas-Fuco1" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/terorie"><img src="https://avatars.githubusercontent.com/u/21371810?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Richard Patel</b></sub></a><br /><a href="#platform-terorie" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="https://github.com/Andy1978"><img src="https://avatars.githubusercontent.com/u/240064?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Andreas Weber</b></sub></a><br /><a href="#ideas-Andy1978" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/vapniks"><img src="https://avatars.githubusercontent.com/u/174330?v=4?s=50" width="50px;" alt=""/><br /><sub><b>vapniks</b></sub></a><br /><a href="#platform-vapniks" title="Packaging/porting to new platform">📦</a></td>

Andrea Borruso

🤔 🎨

Shaun Jackman

🤔

Fred Trotter

🤔 🎨

komosa

🤔

jungle-boogie

🤔

Thomas Klausner

🚇

Stephen Kitt

📦

Leah Neukirchen

🤔

Luigi Baldoni

📦

Hiroaki Yutani

🤔

Daniel M. Drucker

🤔

Nikos Alexandris

🤔

kundeng

📦

Victor Sergienko

📦

Adrian Ho

🎨

zachp

📦

Jakub Podlaha

🎨

Miodrag Milić

📦

Derek Mahar

🤔

spmundi

🤔

Peter Körner

🛡️

rubyFeedback

🤔

rbolsius

📦

awildturtok

🤔

agguser

🤔

jganong

🤔

Fulvio Scapin

🤔

Jordan Torbiak

🤔

Zombo

📦

Brian Fulton-Howard

📦

ChCyrill

🤔

Jauder Ho

💻

Paweł Sacawa

🐛

schragge

📖

Jordi

📖 🤔

本项目遵循 all-contributors 规范。欢迎任何形式的贡献!