返回列表 发帖
@echo off&setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (a.txt) do (
    if defined flag (
        for /f "tokens=1,6" %%b in ("%%a") do (
            if /i "%%b"=="AVGE" set "flag=" & echo,!Num!
            set "Num=%%c"
        )
    )
    if /i "%%a"=="D 11  Final seasonally adjusted data" set flag=1
)
pauseCOPY

TOP

回复 9# inflikt


    我用附件测试没有问题,5613.92

TOP

本帖最后由 apang 于 2013-10-23 09:16 编辑

这样试试呢?
@echo off&setlocal enabledelayedexpansion
(for %%i in (*.txt) do (
    set "Num=" & set "flag="
    for /f "usebackq tokens=1*" %%a in ("%%i") do (
        set "str=%%a %%b"
        if defined flag (
            if /i "%%a"=="AVGE" set "flag=" & echo,!Num!
            for %%c in (!str!) do set "Num=!a!" & set "a=%%c"
        )
        if /i "!str: =!"=="D11Finalseasonallyadjusteddata" set flag=1
    )
))>$
move $ Result.txt
pauseCOPY
1

评分人数

    • foxJL: 乐于助人技术 + 1

TOP

蛋疼,试试vbs先,明天再说
Set fso = CreateObject("Scripting.FileSystemObject")
strKey ="D *11  Final seasonally adjusted data"
For Each file in fso.GetFolder(".").Files
    If LCase(Right(file.Name,4)) = ".txt" Then
        RegEx fso.OpenTextFile(file).ReadAll
    End If
Next
Sub RegEx(text)
    Set re = New RegExp
    re.Pattern = strKey & "[\s\S]+?([^ ]+) +[^ ]+\s+AVGE"
    re.IgnoreCase = True
    For Each a In re.Execute(text)
        fso.OpenTextFile("Result.txt",8,True).WriteLine a.SubMatches(0)
    Next
End SubCOPY

TOP

回复 16# inflikt


    14#改一下,试试看

TOP

返回列表