回复 8# idctop
在 7 楼基础上加入了 mysql 导入代码, 注意 BAT 文件保存为 ANSI 编码, 经测试 "[标签:内容]这样内容整行" 是完全可以正常过滤掉的.
这一部分的字母大小写不要修改mysql -h127.0.0.1 -P3306 -uroot -p123456 -Dgupiao -e COPY 完全代码 | @if(0)==(0) echo off | | set str="code,name,description,market,suggestion,closing_price,price,exchange rate,price earnings ratio,the main cost,institutional participation" | | dir /b *.txt | cscript -nologo -e:jscript %0 %str% | | | | for /f "delims=" %%a in ('dir /b *.txt') do ( | | echo %%a | | mysql -h127.0.0.1 -P3306 -uroot -p123456 -Dgupiao -e "LOAD DATA LOCAL INFILE '%%a' INTO TABLE `sszjlx` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES (`code`, `name`, `description`, `market`, `suggestion`, `closing_price`, `price`, `exchange rate`, `price earnings ratio`, `the main cost`, `institutional participation`);" | | ) | | | | pause & exit | | @end | | var fso = new ActiveXObject("Scripting.FileSystemObject"); | | var s = WScript.Arguments.Item(0); | | var re = new RegExp("^" + s, "i"); | | var reg = /.*\[标签:内容\].*/g; | | var fso = new ActiveXObject("Scripting.FileSystemObject"); | | while (!WScript.StdIn.AtEndOfStream){ | | var filename = WScript.StdIn.Readline(); | | var text = adoLoadText(filename, 'UTF-8').replace(/\r?\n/ig,''); | | while (!(re.test(text))){ | | text = s + "\r\n" + text.replace(/&sbquo/ig,',').replace(/","/ig,'\r\n').replace(reg,''); | | TextToFile(text, filename); | | } | | } | | | | function adoLoadText(filename, charset) { | | var fs, text; | | fs = new ActiveXObject("ADODB.Stream"); | | fs.type = 2; | | fs.charset = charset; | | fs.open(); | | fs.loadFromFile(filename); | | text = fs.readText(-1); | | fs.close(); | | return text; | | } | | | | function TextToFile(text, filename) { | | var fs = new ActiveXObject("Adodb.Stream"); | | fs.Charset = 'UTF-8'; | | fs.Open(); | | fs.WriteText(text); | | fs.SaveToFile(filename, 2); | | fs.Close(); | | }COPY |
|