{"id":344125,"date":"2023-01-18T15:00:34","date_gmt":"2023-01-18T15:00:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344125"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344125","title":{"rendered":"<span>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Miller<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/r2\/3b\/-u\/r23b-ui4ymbcto9uyy-vzm7ajxa.png\" data-src=\"https:\/\/habrastorage.org\/webt\/r2\/3b\/-u\/r23b-ui4ymbcto9uyy-vzm7ajxa.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/www.smashingmagazine.com\/2022\/12\/guide-command-line-data-manipulation-cli-miller\/\">\u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/\">Miller<\/a> \u2014 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u043c, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u043c \u0438 \u043c\u043e\u0449\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 (Command Line Interface, CLI) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 CSV, JSON \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"ustanovka\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p>  <\/p>\n<ul>\n<li>Linux: <code>apt-get install miller<\/code><\/li>\n<li>macOS: <code>brew install miller<\/code><\/li>\n<li>Windows: <code>choco install miller<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 Miller, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --version<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/le\/vm\/az\/levmazu6dybibmyrxmg8keoruck.png\" data-src=\"https:\/\/habrastorage.org\/webt\/le\/vm\/az\/levmazu6dybibmyrxmg8keoruck.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u043e\u0449\u0438 (\u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr help topics<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"signatura-komandy\">\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/h2>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b Miller \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr [input\/output file formats] [verbs] [file] # \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 mlr --csv filter '$color != \"red\"' example.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>--csv<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e) \u0444\u0430\u0439\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f CSV;<\/li>\n<li><code>filter<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0443\u044e \u0441 \u0444\u0430\u0439\u043b\u043e\u043c (\u0433\u043b\u0430\u0433\u043e\u043b \u2014 verb). \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043f\u043e\u043b\u044f <code>color<\/code> \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>red<\/code>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0433\u043b\u0430\u0433\u043e\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>sort<\/code> \u0438 <code>cut<\/code> (\u0441\u043c. \u043d\u0438\u0436\u0435);<\/li>\n<li><code>example.csv<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"obzor-operaciy\">\u041e\u0431\u0437\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/h2>\n<p>  <\/p>\n<h3 id=\"dannye\">\u0414\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>  <\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c <a href=\"https:\/\/raw.githubusercontent.com\/smashingmagazine\/command-line-data-manipulation\/main\/tv_ratings.csv\">\u0420\u0435\u0439\u0442\u0438\u043d\u0433 IMDb \u0430\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0438\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u043e\u0432<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0413\u043b\u0430\u0433\u043e\u043b <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/reference-verbs\/#head\">head<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 10 \u0441\u0442\u0440\u043e\u043a \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr ---csv head .\/tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/le\/ip\/aa\/leipaajdzuszznkr5t_sggo20ci.png\" data-src=\"https:\/\/habrastorage.org\/webt\/le\/ip\/aa\/leipaajdzuszznkr5t_sggo20ci.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 <code>--opprint<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --csv --opprint head .\/tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/lr\/ny\/xf\/lrnyxf5wpprwf5zuqrs3y-e4-p4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/lr\/ny\/xf\/lrnyxf5wpprwf5zuqrs3y-e4-p4.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0424\u043b\u0430\u0433 <code>--c2p<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0444\u043b\u0430\u0433\u043e\u0432 <code>--csv --opprint<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"cepochka-komand\">\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434<\/h3>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>then<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0433\u043b\u0430\u0433\u043e\u043b\u044b \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u0442.\u0435. \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 (\u0441\u043c. \u043d\u0438\u0436\u0435).<\/p>\n<p>  <\/p>\n<h3 id=\"udalenie-kolonok\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043e\u043a<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u043b\u043e\u043d\u043a\u0430 <code>titleId<\/code> \u043d\u0435 \u043d\u0435\u0441\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0423\u0434\u0430\u043b\u0438\u043c \u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043b\u0430\u0433\u043e\u043b\u0430 <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/reference-verbs\/#cut\">cut<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p cut -x -f titleId then head .\/tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>-f<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f (\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e);<\/li>\n<li><code>-x<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430, \u0430 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0435\u0433\u043e (\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e).<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/nn\/v9\/9d\/nnv99dbpvj5wu2u5eslvfddpjio.png\" data-src=\"https:\/\/habrastorage.org\/webt\/nn\/v9\/9d\/nnv99dbpvj5wu2u5eslvfddpjio.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"filtraciya\">\u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0433\u043e\u043b <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/reference-verbs\/#filter\">filter<\/a>. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 10 (\u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0432 \u0444\u0430\u0439\u043b\u0435) \u0441\u0435\u0440\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u0437\u043e\u043d\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p filter '$seasonNumber == 1' then head .\/tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/0-\/rz\/tf\/0-rztfztjscjrcth_pyekdv6trs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/0-\/rz\/tf\/0-rztfztjscjrcth_pyekdv6trs.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"sortirovka\">\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0433\u043e\u043b <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/reference-verbs\/#sort\">sort<\/a>. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 10 \u0441\u0435\u0440\u0438\u0439 \u0441 \u0441\u0430\u043c\u044b\u043c\u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u043c\u0438 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p sort -nr av_rating then head .\/tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>-nr<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043d\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 (\u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443) \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 (\u043d\u0443\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c\u0438).<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/rx\/nv\/n3\/rxnvn32ekmd-hybrtgnh8o-t5ec.png\" data-src=\"https:\/\/habrastorage.org\/webt\/rx\/nv\/n3\/rxnvn32ekmd-hybrtgnh8o-t5ec.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"sohranenie-rezultata-operaciy\">\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/h3>\n<p>  <\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>><\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --csv sort -nr av_rating .\/tv_ratings.csv > .\/sorted_tv_ratings.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/cx\/s2\/hh\/cxs2hhtejf2ojz14owcooindfb0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/cx\/s2\/hh\/cxs2hhtejf2ojz14owcooindfb0.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"preobrazovanie-csv-v-json\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 CSV \u0432 JSON<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f CSV \u0432 JSON \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 <code>--c2j<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2j sort -nr av_rating .\/tv_ratings.csv > .\/sorted_tv_ratings.json<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ui\/cd\/bo\/uicdbokesqguhax2y3oxdqxnr70.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ui\/cd\/bo\/uicdbokesqguhax2y3oxdqxnr70.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h2 id=\"zadacha\">\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Miller \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 5 \u0441\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d\u043e\u0432, \u0437\u0430\u0432\u043e\u0435\u0432\u0430\u0432\u0448\u0438\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0434\u0430\u043b\u0435\u0439 \u043d\u0430 \u043e\u043b\u0438\u043c\u043f\u0438\u0430\u0434\u0435 \u0432 \u0420\u0438\u043e-\u0434\u0435-\u0416\u0430\u043d\u0435\u0439\u0440\u043e \u0432 2016 \u0433\u043e\u0434\u0443.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c <a href=\"https:\/\/raw.githubusercontent.com\/flother\/rio2016\/master\/athletes.csv\">\u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 CSV<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p head .\/athletes.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/wx\/9k\/c1\/wx9kc1njzyrn5pzmix-dszcf6jw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/wx\/9k\/c1\/wx9kc1njzyrn5pzmix-dszcf6jw.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u043e\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --csv -I cut -x -f id,info,weight,height,date_of_birth .\/athletes.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>-I<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0442.\u0435. \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0437\u0430\u0442\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c. \u043f\u0435\u0440.:<\/em> \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0430 \u0437\u0430\u043f\u0438\u0448\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b <code>athletes_formatted.csv<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr -c cut -x -f id,info,weight,height,date_of_birth .\/athletes.csv > .\/athletes_formatted.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>-c<\/code> \u2014 \u044d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f <code>--csv<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zd\/mh\/li\/zdmhliqjzcmr2ylft9tvz0gfdtc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/zd\/mh\/li\/zdmhliqjzcmr2ylft9tvz0gfdtc.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043e\u043b\u043e\u0442\u044b\u0445, \u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u044b\u0445 \u0438 \u0431\u0440\u043e\u043d\u0437\u043e\u0432\u044b\u0445 \u043c\u0435\u0434\u0430\u043b\u0435\u0439. \u041e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0434\u0430\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043b\u0430\u0433\u043e\u043b\u0430 <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/reference-verbs\/#put\">put<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p put '$medals=$bronze+$silver+$gold' then head .\/athletes_formatted.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/kk\/ma\/-r\/kkma-rabz3en9_iyemifqjqcjie.png\" data-src=\"https:\/\/habrastorage.org\/webt\/kk\/ma\/-r\/kkma-rabz3en9_iyemifqjqcjie.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043c\u0435\u0434\u0430\u043b\u0435\u0439 \u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p put '$medals=$bronze+$silver+$gold' \\ then sort -nr medals \\ then head .\/athletes_formatted.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/vl\/g2\/yw\/vlg2yw4f5jqmdpxv3h6sebrsrvk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/vl\/g2\/yw\/vlg2yw4f5jqmdpxv3h6sebrsrvk.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u043f\u044f\u0442\u044c\u044e \u0441\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 <code>-n<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p put '$medals=$bronze+$silver+$gold' \\ then sort -nr medals \\ then head -n 5 .\/athletes_formatted.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/lz\/es\/zt\/lzesztakos0n6setbxqmvbzz-gw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/lz\/es\/zt\/lzesztakos0n6setbxqmvbzz-gw.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 JSON-\u0444\u0430\u0439\u043b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2j put '$medals=$bronze+$silver+$gold' \\ then sort -nr medals \\ then head -n 5 .\/athletes.csv > .\/top5_athletes.json<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/e8\/cu\/wp\/e8cuwp1vnjzxf_zsrjsy_j23kfs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/e8\/cu\/wp\/e8cuwp1vnjzxf_zsrjsy_j23kfs.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>-j<\/code> \u2014 \u044d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f <code>--json<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u044f\u0442\u0435\u0440\u043a\u0443 \u043b\u0443\u0447\u0448\u0438\u0445 \u0430\u0442\u043b\u0435\u0442\u043e\u0432 \u0441\u0440\u0435\u0434\u0438 \u0436\u0435\u043d\u0449\u0438\u043d? \u041f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">mlr --c2p put '$medals=$bronze+$silver+$gold' \\ then sort -nr medals \\ then filter '$sex == \"female\"' \\ then head -n 5 .\/athletes_formatted.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/jw\/-u\/zx\/jw-uzxtfztlbkjne0kq4yk-ijao.png\" data-src=\"https:\/\/habrastorage.org\/webt\/jw\/-u\/zx\/jw-uzxtfztlbkjne0kq4yk-ijao.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0432\u044b, \u043a\u0430\u043a \u0438 \u044f, \u0443\u0437\u043d\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0438 \u043d\u0435 \u0437\u0440\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/timeweb.cloud\/?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=vds-promo-6-rub\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/711246\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/711246\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/r2\/3b\/-u\/r23b-ui4ymbcto9uyy-vzm7ajxa.png\" data-src=\"https:\/\/habrastorage.org\/webt\/r2\/3b\/-u\/r23b-ui4ymbcto9uyy-vzm7ajxa.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/www.smashingmagazine.com\/2022\/12\/guide-command-line-data-manipulation-cli-miller\/\">\u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e <a href=\"https:\/\/miller.readthedocs.io\/en\/latest\/\">Miller<\/a> \u2014 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u043c, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u043c \u0438 \u043c\u043e\u0449\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 (Command Line Interface, CLI) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 CSV, JSON \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-344125","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=344125"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344125\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}