{"id":59172,"date":"2018-04-25T08:40:22","date_gmt":"2018-04-24T23:40:22","guid":{"rendered":"https:\/\/www.softantenna.com\/wp\/?p=59172"},"modified":"2018-04-25T08:40:22","modified_gmt":"2018-04-24T23:40:22","slug":"textql","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/textql\/","title":{"rendered":"TextQL - CVS\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u3057\u3066SQL\u3092\u5b9f\u884c\u3067\u304d\u308b\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30c4\u30fc\u30eb"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2018\/04\/s_20180423_204550.jpg\" alt=\"S 20180423 204550\" title=\"s_20180423_204550.jpg\" border=\"0\" width=\"863\" height=\"600\" \/><\/p>\n<p>CSV\u30d5\u30a1\u30a4\u30eb\u3084TSV\u30d5\u30a1\u30a4\u30eb\u306f\u3055\u307e\u3056\u307e\u306a\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3067\u304d\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7684\u306a\u69cb\u9020\u3092\u6301\u3064\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u304c\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u4f7f\u7528\u3067\u304d\u308b\u4fbf\u5229\u306aSQL\u8a00\u8a9e\u306f\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u8868\u8a08\u7b97\u30bd\u30d5\u30c8\u306b\u53d6\u308a\u8fbc\u3093\u3067\u30c7\u30fc\u30bf\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u3082\u306e\u306e\u3001SQL\u306b\u6163\u308c\u89aa\u3057\u3093\u3060\u65b9\u306a\u3089\u3070\u3001SQL\u3092\u4f7f\u3063\u3066\u76f4\u63a5\u4f5c\u696d\u3057\u305f\u3044\u3068\u601d\u3063\u305f\u7d4c\u9a13\u306e\u3042\u308b\u65b9\u3082\u591a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300c<a href=\"https:\/\/github.com\/dinedal\/textql\">TextQL<\/a>\u300d\u306f\u3053\u306e\u30a2\u30a4\u30c7\u30a2\u306b\u57fa\u3065\u3044\u3066\u958b\u767a\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30c4\u30fc\u30eb\u3067\u3059\u3002\u30b5\u30f3\u30d5\u30e9\u30f3\u30b9\u306e\u30bd\u30d5\u30c8\u30a8\u30f3\u30b8\u30cb\u30a2Paul Bergeron\u6c0f\u306b\u3088\u3063\u3066\u4f5c\u6210\u3055\u308c\u305fGo\u8a00\u8a9e\u88fd\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30bd\u30d5\u30c8\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>SQLite\u3067CSV\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u308a\u8fbc\u3093\u3067\u3082\u540c\u3058\u3088\u3046\u306a\u4f5c\u696d\u304c\u53ef\u80fd\u3067\u3059\u304c\u3001\u6b21\u306b\u793a\u3059\u3088\u3046\u306a\u9055\u3044\u304c\u3042\u308b\u3068\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<ul>\n<li>sqlite\u30a4\u30f3\u30dd\u30fc\u30c8\u306f\u6a19\u6e96\u5165\u529b\u3092\u53d7\u3051\u53d6\u3089\u305aUNIX\u30d1\u30a4\u30d7\u3092\u7834\u58ca\u3059\u308b<\/li>\n<li>textql\u306f\u30af\u30aa\u30fc\u30c8\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u305f\u30c7\u30ea\u30df\u30bf\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b<\/li>\n<li>textql\u306fsqlite\u306e\u30e1\u30e2\u30ea\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u6a5f\u80fd\u3092\u6d3b\u7528\u3057\u5fc5\u8981\u306a\u5834\u5408\u3060\u3051\u30c7\u30a3\u30b9\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u4f7f\u7528\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>TextQL\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h2>\n<p>Mac\u306e\u5834\u5408Homebrew\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3059\u3002<\/p>\n<pre>\nbrew install textql\n<\/pre>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u306b\u306f\u30bd\u30fc\u30b9\u304b\u3089\u30d3\u30eb\u30c9\u3059\u308b\u65b9\u6cd5\u3084\u3001Docker\u3067\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306a\u3069\u3001\u305d\u306e\u4ed6\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u3082\u63b2\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002Mac\u4ee5\u5916\u3067\u4f7f\u7528\u3059\u308b\u5834\u5408\u306a\u3069\u306f\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>TextQL\u306e\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>\u307e\u305a\u4f7f\u7528\u3059\u308b\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066sample_data.csv\u3092\u6e96\u5099\u3057\u307e\u3059\u3002<\/p>\n<pre>\nid,name,value,timestamp\n3,\u5c71\u7530,5,1440378750\n1,\u7530\u4e2d,16,1440378790\n2,\u9234\u6728,-3,1440378668\n<\/pre>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u3057\u3066\u884c\u6570\u3092\u554f\u3044\u5408\u308f\u305b\u308bSELECT\u6587\u306a\u3069\u304c\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\n$ textql -sql \"select count() from sample_data\" sample_data.csv\n4\n<\/pre>\n<p>1\u884c\u76ee\u306e\u30d8\u30c3\u30c0\u30fc\u3092\u9664\u5916\u3057\u305f\u3044\u5834\u5408\u300c-header\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\ntextql -header -sql \"select count() from sample_data\" sample_data.csv\n3\n<\/pre>\n<p>max\u3067\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\n$ textql -header -sql \"select max(value) from sample_data\" sample_data.csv\n16\n<\/pre>\n<p>SQLite\u5f62\u5f0f\u306eDB\u306b\u4fdd\u5b58\u3057\u305f\u308a\u3001\u5225\u306eCSV\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u305f\u308a\u3068\u3044\u3063\u305f\u51e6\u7406\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre>\n# SQLite\u5f62\u5f0f\u3067\u4fdd\u5b58\n$ textql -save-to .\/output.db -header -sql \"id, name order by timestamp\" sample_data.csv\n2,\u9234\u6728\n3,\u5c71\u7530\n1,\u7530\u4e2d\n# sqlite3\u3067\u64cd\u4f5c\n$ sqlite3 .\/output.db \"select * from sample_data\"\n3|\u5c71\u7530|5|1440378750\n1|\u7530\u4e2d|16|1440378790\n2|\u9234\u6728|-3|1440378668\n# \u5225\u306eCSV\u3067\u4fdd\u5b58\n$ textql -output-file .\/output.csv -header -sql \"id, name order by timestamp\" sample_data.csv\n$ cat output.csv\n2,\u9234\u6728\n3,\u5c71\u7530\n1,\u7530\u4e2d\n<\/pre>\n<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2018\/04\/s_20180423_204810.jpg\" alt=\"S 20180423 204810\" title=\"s_20180423_204810.jpg\" border=\"0\" width=\"904\" height=\"385\" \/><\/p>\n<p>SQL\u306b\u6163\u308c\u305f\u65b9\u306a\u3089\u3070\u305d\u308c\u307b\u3069\u96e3\u3057\u304f\u306a\u3044\u64cd\u4f5c\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u5404\u7a2e\u30b3\u30de\u30f3\u30c9\u306f\u7701\u7565\u5f62\u3082\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002\u8a73\u3057\u304f\u306f\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u52d5\u753b\u3067\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044(\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306f\u7121\u3057?)<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>TextQL\u3092\u4f7f\u7528\u3059\u308c\u3070\u3001SQL\u3092\u4f7f\u7528\u3057\u3066\u76f4\u611f\u7684\u306bCSV\u3084TSV\u30d5\u30a1\u30a4\u30eb\u3092\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002CSV\u3084TSV\u3092\u6271\u3046\u6a5f\u4f1a\u304c\u591a\u304f\u3001\u304b\u3064SQL\u306b\u6163\u308c\u3066\u3044\u308b\u65b9\u306f\u8a66\u3057\u3066\u307f\u3066\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSV\u30d5\u30a1\u30a4\u30eb\u3084TSV\u30d5\u30a1\u30a4\u30eb\u306f\u3055\u307e\u3056\u307e\u306a\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3067\u304d\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7684\u306a\u69cb\u9020\u3092\u6301\u3064\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u304c\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u4f7f\u7528\u3067\u304d\u308b\u4fbf\u5229\u306aSQL\u8a00\u8a9e\u306f\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002 \u8868\u8a08\u7b97\u30bd\u30d5\u30c8\u306b\u53d6\u308a\u8fbc\u3093\u3067\u30c7\u30fc\u30bf\u3092\u6d3b\u7528\u3059\u308b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":59174,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3459],"tags":[2893],"class_list":["post-59172","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","tag-sql"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/59172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=59172"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/59172\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/59174"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=59172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=59172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=59172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}