{"id":1261,"date":"2018-03-22T21:06:11","date_gmt":"2018-03-22T12:06:11","guid":{"rendered":"http:\/\/esoro.jp\/?p=1261"},"modified":"2018-03-22T21:06:11","modified_gmt":"2018-03-22T12:06:11","slug":"ado%e3%81%a7csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e8%aa%ad%e3%81%bf%e8%be%bc%e3%82%80%e3%81%a8255%e6%96%87%e5%ad%97%e4%bb%a5%e4%b8%8a%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ab%e3%81%aa","status":"publish","type":"post","link":"https:\/\/esoro.jp\/?p=1261","title":{"rendered":"ADO\u3067CSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3068255\u6587\u5b57\u4ee5\u4e0a\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b"},"content":{"rendered":"<p>\u3000\u3061\u3087\u3063\u3068\u524d\u306bVBScript\u3067\u4f5c\u3089\u308c\u305f\u30c4\u30fc\u30eb\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u6700\u8fd1\u306b\u306a\u3063\u3066\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3068\u306e\u9023\u7d61\u3002<br \/>\n\u30a8\u30e9\u30fc\u306b\u306a\u308b\u30b1\u30fc\u30b9\u306f\u3001CSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067255Byte\u3092\u8d85\u3048\u3066\u3044\u308b\u5024\u3092\u6271\u3046\u6642\u3068\u5224\u660e\u3002<br \/>\n\u5bfe\u8c61\u306e\u30c4\u30fc\u30eb\u306f\u5b9f\u88c5\u4e0aADO\u304c\u4f7f\u308f\u308c\u3066\u304a\u308a\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306bCSV\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true \" title=\"ADODB\" >Set objADO = CreateObject(\"ADODB.Connection\")\r\nobjADO.Open \"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a9\u30eb\u30c0;ReadOnly=1}\"\r\nSet objRS = objADO.Execute(\"select * from CSV\u30d5\u30a1\u30a4\u30eb\u540d\")\r\n\r\nDo Until objRS.Eof = True\r\n   '\uff11\u756a\u76ee\u306e\u9805\u76ee\r\n   colum1 = objRS(0)\r\n'\u5177\u4f53\u7684\u306a\u51e6\u7406\u306f\u7701\u7565\r\n   objRS.MoveNext\r\nLoop\r\n<\/pre>\n<p> \u5bfe\u8c61\u306eCSV\u30d5\u30a1\u30a4\u30eb\u304c\u6539\u884c\u3092\u542b\u3080\u5024\u3092\u6271\u3046\u90fd\u5408\u3067ADO\u3092\u4f7f\u3063\u305f\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3084\u3089\u3001CSV\u30c6\u30ad\u30b9\u30c8\u30c9\u30e9\u30a4\u30d0\u3068\u3057\u3066\u306e\u4ed5\u69d8\u4e0a\u3001255\u3092\u8d85\u3048\u308b\u9805\u76ee\u6570\u3060\u3063\u305f\u308a\u3001255\u3092\u8d85\u3048\u308b\u30b5\u30a4\u30ba\u3068\u3044\u3063\u305f\u3001\u6614\u306a\u304c\u3089\u306e\u58c1\u304c\u3042\u308b\u6a21\u69d8\u3002<br \/>\n\u56de\u907f\u7b56\u3068\u3057\u3066\u306f\u3001Schema.ini\u3067\u9003\u3052\u308b\u306e\u304c\u5b9a\u756a\u3089\u3057\u3044\u306e\u3067\u3059\u304c\u3001\u8a66\u3057\u305f\u3068\u3053\u308d\u30a8\u30e9\u30fc\u306b\u306f\u306a\u3089\u306a\u3044\u304c\u3001255\u6587\u5b57\u8d85\u304c\u52dd\u624b\u306b\u5207\u3089\u308c\u308b\u5f62\u306b\u30fb\u30fb\u30fb<\/p>\n<p> \u3068\u3044\u3046\u304b\u3001\u3053\u308c\u4ee5\u4e0aADODB\u306b\u3064\u3044\u3066\u8abf\u3079\u308b\u6642\u9593\u304c\u7121\u99c4\uff01\uff01\u306a\u306e\u3067\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u3068\u3057\u3066\u4f5c\u308a\u76f4\u3057\u307e\u3057\u305f\u3002\u3002<\/p>\n<p> <a href=\"https:\/\/teratail.com\/questions\/73613\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3092\u5c11\u3057\u53c2\u8003\u306b\u3057\u3066\u3001\u3055\u3089\u306b\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u5185\u306e\u30ab\u30f3\u30de\u3082\u8003\u616e\u3057\uff08\u3053\u3053\u3067\u306f\u30ab\u30f3\u30de\u306f\u524a\u9664\u3057\u3066\u307e\u3059\uff09\u3001ADO\u306e\u30ec\u30b3\u30fc\u30c9\u30bb\u30c3\u30c8\u3063\u307d\u304f\uff11\u30ec\u30b3\u30fc\u30c9\u6bce\u306b\u914d\u5217\u3078\u5217\u306e\u5024\u3092\u30bb\u30c3\u30c8\u3057\u3066\u304b\u3089\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true \" title=\"readcsv.vbs\" >Const sCsvFileName = \"C:\\Users\\XXX\\data.csv\"\r\nDim objFSO\r\nDim objFile\r\nDim strLine,SpltTmp\r\nDim i,iDimPos,colum1\r\n\r\nSet objFSO = CreateObject(\"Scripting.FileSystemObject\") \r\nSet objFile = objFSO.OpenTextFile(sCsvFileName)\r\n\r\nDo While objFile.AtEndOfStream &lt;&gt; True\r\n     'CSV\u5217\u306e\u6700\u5927\u6570\r\n     Redim strRec(12)\r\n     strLine = \"\"\r\n     Do While objFile.AtEndOfStream &lt;&gt; True\r\n        strLine = strLine + objFile.ReadLine\r\n        If (Len(strLine) - Len(Replace(strLine,\"\"\"\",\"\"))) Mod 2 = 0 Then Exit Do\r\n        strLine = strLine + vbNewLine\r\n     Loop\r\n     iDimPos = 0\r\n     For Each SpltTmp In Split(strLine,\",\")\r\n        If iDimPos &gt; 11 Then\r\n           Exit For\r\n        End If\r\n        If Instr(SpltTmp,\"\"\"\") = 0 Then\r\n           strRec(iDimPos) = SpltTmp\r\n           iDimPos = iDimPos + 1\r\n        ElseIf Instr(SpltTmp,\"\"\"\") = 1 And InStrRev(SpltTmp,\"\"\"\") = Len(SpltTmp) Then\r\n           If Instr(1, SpltTmp, \"\"\"\") = 2 Then\r\n              strRec(iDimPos) = \"\"\r\n           Else\r\n              strRec(iDimPos) = Mid(SpltTmp,2,Len(SpltTmp)-2)\r\n           End If\r\n           iDimPos = iDimPos + 1\r\n        Else \r\n           strRec(iDimPos) = strRec(iDimPos) + SpltTmp\r\n           If InStrRev(SpltTmp,\"\"\"\") = Len(SpltTmp) Then\r\n              strRec(iDimPos) = Mid(strRec(iDimPos),2, Len(strRec(iDimPos))-2)\r\n              iDimPos = iDimPos + 1\r\n           End If\r\n        End If\r\n     Next\r\n\r\n   '\uff11\u756a\u76ee\u306e\u9805\u76ee\r\n   colum1 = strRec(0)\r\n'\u5177\u4f53\u7684\u306a\u51e6\u7406\u306f\u7701\u7565\r\nLoop\r\n\r\nobjFile.Close\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3061\u3087\u3063\u3068\u524d\u306bVBScript\u3067\u4f5c\u3089\u308c\u305f\u30c4\u30fc\u30eb\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u6700\u8fd1\u306b\u306a\u3063\u3066\u30a8\u30e9\u30fc &hellip; <a href=\"https:\/\/esoro.jp\/?p=1261\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1261"}],"collection":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1261"}],"version-history":[{"count":0,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1261\/revisions"}],"wp:attachment":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}