Excel 筛选txt文本中的特定内容 并保存到新的表中 Filter extract expected keyword/word

比如有一个超长的txt文本,文本中的东西是循环的,类似于输出文件,那么

我想找到特定内容(为什么是特定内容,因为输出的时候已经估计Mark了一下)

然后使用字符分割,取出来想要的数据。

PS: 当然也可以在写txt文本的时候新增加一个文件指针,添加数据,只不过为了减少文件输出,提高效率,因此这么做。

If we want to extract the data with keyword from a very long txt file we can use filter+mid function

【1】First, import txt file using Excel Native tools

e.g OpenFoam simpleFoam:

/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 7-1ff648926f77
Exec   : simpleFoam
Date   : Jan 23 2021
Time   : 19:27:50
Host   : "ubuntu"
PID    : 46574
I/O    : uncollated
Case   : /home/God/OpenFOAM/GOD-7/run/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


SIMPLE: Convergence criteria found
        p: tolerance 0.01
        U: tolerance 0.001
        "(k|epsilon|omega|f|v2)": tolerance 0.001

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
RAS
{
    RASModel        kEpsilon;
    turbulence      on;
    printCoeffs     on;
    Cmu             0.09;
    C1              1.44;
    C2              1.92;
    C3              0;
    sigmak          1;
    sigmaEps        1.3;
}

No MRF models present

No finite volume options present

Starting time loop

streamLine streamlines:
    automatic track length specified through number of sub cycles : 5

Time = 1

smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 0.0538101, No Iterations 1
smoothSolver:  Solving for Uy, Initial residual = 1, Final residual = 0.030925, No Iterations 2
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.068427, No Iterations 17
time step continuity errors : sum local = 1.19733, global = 0.179883, cumulative = 0.179883
smoothSolver:  Solving for epsilon, Initial residual = 0.23288, Final residual = 0.0114612, No Iterations 3
bounding epsilon, min: -1.98669 max: 1033.28 average: 35.8884
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 0.0454552, No Iterations 3
ExecutionTime = 0.15 s  ClockTime = 0 s

Time = 2

smoothSolver:  Solving for Ux, Initial residual = 0.438346, Final residual = 0.0305667, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.290564, Final residual = 0.0257883, No Iterations 4
GAMG:  Solving for p, Initial residual = 0.0522496, Final residual = 0.00435174, No Iterations 15
time step continuity errors : sum local = 3.97186, global = 0.123248, cumulative = 0.303131
smoothSolver:  Solving for epsilon, Initial residual = 0.176548, Final residual = 0.010301, No Iterations 3
bounding epsilon, min: -10.4236 max: 23808.9 average: 70.8793
smoothSolver:  Solving for k, Initial residual = 0.436479, Final residual = 0.0394786, No Iterations 3
ExecutionTime = 0.18 s  ClockTime = 0 s

Time = 3

smoothSolver:  Solving for Ux, Initial residual = 0.1242, Final residual = 0.0111197, No Iterations 4
smoothSolver:  Solving for Uy, Initial residual = 0.216892, Final residual = 0.0156466, No Iterations 4
GAMG:  Solving for p, Initial residual = 0.14275, Final residual = 0.0119489, No Iterations 6
time step continuity errors : sum local = 3.34307, global = 0.328383, cumulative = 0.631514
smoothSolver:  Solving for epsilon, Initial residual = 0.175551, Final residual = 0.00809994, No Iterations 2
bounding epsilon, min: -898.39 max: 45796.5 average: 117.634
smoothSolver:  Solving for k, Initial residual = 0.191738, Final residual = 0.0156143, No Iterations 3
ExecutionTime = 0.19 s  ClockTime = 0 s

Time = 4

smoothSolver:  Solving for Ux, Initial residual = 0.0677471, Final residual = 0.00434826, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.10749, Final residual = 0.00821448, No Iterations 4
GAMG:  Solving for p, Initial residual = 0.1061, Final residual = 0.0105576, No Iterations 6
time step continuity errors : sum local = 1.74649, global = 0.177143, cumulative = 0.808657
smoothSolver:  Solving for epsilon, Initial residual = 0.0706245, Final residual = 0.00578441, No Iterations 2
bounding epsilon, min: -172.106 max: 53276.8 average: 128.968
smoothSolver:  Solving for k, Initial residual = 0.124758, Final residual = 0.0111285, No Iterations 3
ExecutionTime = 0.21 s  ClockTime = 0 s

Time = 5

smoothSolver:  Solving for Ux, Initial residual = 0.0568147, Final residual = 0.00396887, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.0866067, Final residual = 0.00827391, No Iterations 4
GAMG:  Solving for p, Initial residual = 0.104689, Final residual = 0.00807946, No Iterations 4
time step continuity errors : sum local = 1.02737, global = 0.0926034, cumulative = 0.90126
smoothSolver:  Solving for epsilon, Initial residual = 0.0924311, Final residual = 0.00558155, No Iterations 2
smoothSolver:  Solving for k, Initial residual = 0.0862603, Final residual = 0.00509212, No Iterations 4
ExecutionTime = 0.22 s  ClockTime = 0 s

Time = 6

smoothSolver:  Solving for Ux, Initial residual = 0.0518443, Final residual = 0.0038966, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.072437, Final residual = 0.00491558, No Iterations 5
GAMG:  Solving for p, Initial residual = 0.0867032, Final residual = 0.00650266, No Iterations 4
time step continuity errors : sum local = 0.769078, global = -0.0579733, cumulative = 0.843287
smoothSolver:  Solving for epsilon, Initial residual = 0.0532318, Final residual = 0.0030113, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 0.068907, Final residual = 0.00474785, No Iterations 4
ExecutionTime = 0.24 s  ClockTime = 0 s

Time = 7

smoothSolver:  Solving for Ux, Initial residual = 0.0479743, Final residual = 0.0038598, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.0632908, Final residual = 0.00456234, No Iterations 5
GAMG:  Solving for p, Initial residual = 0.0715323, Final residual = 0.0045885, No Iterations 4
time step continuity errors : sum local = 0.540677, global = -0.0673473, cumulative = 0.77594
smoothSolver:  Solving for epsilon, Initial residual = 0.0478442, Final residual = 0.00273446, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 0.0581603, Final residual = 0.00422263, No Iterations 4
ExecutionTime = 0.26 s  ClockTime = 0 s

Time = 8

smoothSolver:  Solving for Ux, Initial residual = 0.0441941, Final residual = 0.00377893, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.0584274, Final residual = 0.00434069, No Iterations 5
GAMG:  Solving for p, Initial residual = 0.0622691, Final residual = 0.00510351, No Iterations 3
time step continuity errors : sum local = 0.605536, global = 0.0149036, cumulative = 0.790843
smoothSolver:  Solving for epsilon, Initial residual = 0.0408377, Final residual = 0.00275532, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 0.0515683, Final residual = 0.00388887, No Iterations 4
ExecutionTime = 0.27 s  ClockTime = 0 s

Time = 9

smoothSolver:  Solving for Ux, Initial residual = 0.0408709, Final residual = 0.00364297, No Iterations 5
smoothSolver:  Solving for Uy, Initial residual = 0.0551718, Final residual = 0.00421331, No Iterations 5
GAMG:  Solving for p, Initial residual = 0.0568794, Final residual = 0.0047445, No Iterations 3
time step continuity errors : sum local = 0.568955, global = 0.00270241, cumulative = 0.793546
smoothSolver:  Solving for epsilon, Initial residual = 0.0421798, Final residual = 0.0028828, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 0.0481629, Final residual = 0.0037254, No Iterations 4
ExecutionTime = 0.29 s  ClockTime = 0 s

【2】2nd use filter with constrains filter that contans the keyword that you are expecting 

 

 

such as

ExecutionTime

 

after using keyword to filter the text, we can get the excepted result

 

 

select then all and then copy them to a new sheet 

【3】Finally, we can use mid() function to extract data and analysis it

 

 

 That‘s all

Jan.24,2021

posted @ 2021-01-24 11:42  千家诗  阅读(696)  评论(0编辑  收藏  举报