{"id":258,"date":"2020-09-01T13:13:13","date_gmt":"2020-09-01T04:13:13","guid":{"rendered":"http:\/\/ringo-apple-web.com\/?p=258"},"modified":"2020-12-19T08:41:29","modified_gmt":"2020-12-18T23:41:29","slug":"csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e6%89%b1%e3%81%86","status":"publish","type":"post","link":"http:\/\/ringo-apple-web.com\/?p=258","title":{"rendered":"CSV\u30d5\u30a1\u30a4\u30eb\u3092\u6271\u3046"},"content":{"rendered":"\n<p>Python\u306b\u4ed8\u3044\u3066\u304f\u308b\u7d44\u307f\u8fbc\u307f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3048\u3070CSV\u30d5\u30a1\u30a4\u30eb\u3082\u6271\u3048\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import csv\n\nwith open(&quot;st.csv&quot;, &quot;w&quot;, newline=&quot;) as f:\n     w = csv.writer(f, delimiter=&quot;,&quot;)\n     w.writerow([&quot;one&quot;, &quot;two&quot;, &quot;threww&quot;])\n     w.write.row([&quot;four&quot;, &quot;five&quot;, &quot;six&quot;])\n\n#\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u65b0\u3057\u304fst.csv\u3092\u4f5c\u308b\n<\/code><\/pre><\/div>\n\n\n\n<p>csv\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3046\u3068\u8aad\u307f\u8fbc\u307f\u3082\u3067\u304d\u308b\u3002csv\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u305f\u3081\u306bopen\u95a2\u6570\u306e\u7b2c2\u5f15\u6570\uff08\u30e2\u30fc\u30c9\uff09\u306b&#8221;r&#8221;\u3092\u6307\u5b9a\u3059\u308b\u3002\u305d\u3057\u3066with\u5206\u306e\u5185\u5074\u3067csv.reader\u30e1\u30bd\u30c3\u30c9\u306b\u30d5\u30a1\u30a4\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u30c7\u30ea\u30df\u30bf\u3068\u3057\u3066\u30ab\u30f3\u30de\u3092\u6307\u5b9a\u3057\u3066\u547c\u3073\u51fa\u3059<\/p>\n\n\n\n<p>\u95a2\u6570\u304b\u3089\u306e\u8fd4\u5024\u3068\u3057\u3066csv\u3092\u4e00\u884c\u5358\u4f4d\u3067\u6271\u3048\u308b\u30a4\u30c6\u30e9\u30d6\u30eb\u304c\u8fd4\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<p><strong>\u30a4\u30c6\u30e9\u30d6\u30eb<\/strong>\u3068\u306f\u7e70\u308a\u8fd4\u3057\u53ef\u80fd\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u3053\u3068\u3067\u30ea\u30b9\u30c8\u3084\u30bf\u30d7\u30eb\u3084range\u95a2\u6570\u3067\u4f5c\u6210\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u3053\u3068\u3067\u3059\u3002 for\u6587\u3067<strong>\u30a4\u30c6\u30e9\u30d6\u30eb<\/strong>\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#\u3053\u3053\u3067\u958b\u304f\u30d5\u30a1\u30a4\u30eb\u306f\u3001\n#\u524d\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3066\n#\u4f5c\u3089\u308c\u307e\u3059\u3002\n\nimport csv\n\nwith open(&quot;st.csv&quot;, &quot;r&quot;) as f:\n     r = csv.reader(f, delimiter=&quot;,&quot;)\n     for row in r:\n         print(&quot;,&quot;.join(row))\n\n&gt;&gt;one,two.three\n&gt;&gt;four,five,six<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306fst.csv\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u3000csv.reader\u30e1\u30bd\u30c3\u30c9\u3067csv\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3057\u3066\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002csv\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092for\u30eb\u30fc\u30d7\u3067\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002\u30eb\u30fc\u30d7\u3054\u3068\u306b\u53d6\u308a\u51fa\u3055\u308c\u305frow\u306e\u8981\u7d20\u3092\u30ab\u30f3\u30de\u3067\u7d50\u5408\u3057\u3066\u51fa\u529b\u3002\u3053\u308c\u3067\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304b\u308c\u3066\u674e\u30b3\u30f3\u30c6\u30f3\u30c4\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u30ab\u30f3\u30de\u3067\u533a\u5207\u3089\u308c\u305f\u6587\u5b57\u5217\u3092\u518d\u73fe\u3067\u304d\u305f\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\">\u7528\u8a9e\u96c6<\/p>\n\n\n\n<p><strong>with\u6587<\/strong>\u3000\u8907\u5408\u6587\u306e\u4e00\u3064\u3067\u51e6\u7406\u304cwith\u30d6\u30ed\u30c3\u30af\u3092\u629c\u3051\u305f\u3068\u304d\u81ea\u52d5\u7684\u306b\u6307\u5b9a\u3057\u305f\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n\n\n\n<p><strong>\u30c7\u30ea\u30df\u30bf<\/strong>\u3000\u533a\u5207\u308a\u6587\u5b57\u3001delimiter\u3002CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u533a\u5207\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b\u8a18\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u306b\u4ed8\u3044\u3066\u304f\u308b\u7d44\u307f\u8fbc\u307f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3048\u3070CSV\u30d5\u30a1\u30a4\u30eb\u3082\u6271\u3048\u308b csv\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3046\u3068\u8aad\u307f\u8fbc\u307f\u3082\u3067\u304d\u308b\u3002csv\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u305f\u3081\u306bopen\u95a2\u6570\u306e\u7b2c2\u5f15\u6570\uff08\u30e2\u30fc\u30c9\uff09\u306b&#8221;r&#8221;\u3092\u6307\u5b9a\u3059\u308b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":262,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[18],"tags":[],"_links":{"self":[{"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/posts\/258"}],"collection":[{"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=258"}],"version-history":[{"count":3,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":265,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/posts\/258\/revisions\/265"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=\/wp\/v2\/media\/262"}],"wp:attachment":[{"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ringo-apple-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}