Hi all. I need some help for a macro to extract data from a .txt file and copy to excel table. In the sample `file.txt` attached, I can have several blocks like this:
1 1 DATA PROOF SAMPLE - PROP FROM CORP D-1807 - DATA FROM PROP1 NOVEMBER 30, 2022 DATA 9/17/18 PAGE 31
2 USER-SUPPLIED ASPECT RATIO - 12/23/88
3 0 SUBCASE 1 - FMETHOD = 30 - SPEED = 1 FT/SEC SUBCASE 1
4 0 VALUES SUMMARY
5 CONFIGURATIO N = DATASG2D XY-SYMMETRY = ASYMMETRIC XZ-SYMMETRY = ASYMMETRIC
6 POINT = 1 MACH NUMBER = 0.1000 DENSITY RATIO = 8.8730E-01 METHOD = PK
7
8
9 KRATIO 1./KRATIO SPEED RATIO MODULE COMPLEX EIGENVALUE
10 125.3487 7.9777470E-03 8.3333333E-02 -9.0001358E-03 9.1199364E+00 -2.5786402E-01 5.7302250E+01
11 1 DATA PROOF SAMPLE - PROP FROM CORP D-1807 - DATA FROM PROP1 NOVEMBER 30, 2022 DATA 9/17/18 PAGE 32
12 USER-SUPPLIED ASPECT RATIO - 12/23/88
13 0 SUBCASE 1 - FMETHOD = 30 - SPEED = 1 FT/SEC SUBCASE 1
14 0 VALUES SUMMARY
15 CONFIGURATIO N = DATASG2D XY-SYMMETRY = ASYMMETRIC XZ-SYMMETRY = ASYMMETRIC
16 POINT = 2 MACH NUMBER = 0.1000 DENSITY RATIO = 8.8730E-01 METHOD = PK
17
18
19 KRATIO 1./KRATIO SPEED RATIO MODULE COMPLEX EIGENVALUE
20 126.4484 7.9083624E-03 8.3333333E-02 -5.9999770E-03 9.1999509E+00 -1.7341432E-01 5.7804996E+01
21
I need a macro to run all lines and, every time it finds a "VALUES SUMMARY" (as at line 4), it gets the value of point (after "POINT =") at line 6, and also the values of speed, ratio and module, at line 10 (under "SPEED", "RATIO" and "MODULE" respectively, at line 9). Next, it will find another "VALUES SUMMARY" at line 14, however, at this time, these data are related to point 2 (as written at line 16), and it needs to get the new value of point (after "POINT ="), and also the values of speed, ratio and module, at line 20 (under "SPEED", "RATIO" and "MODULE" respectively, at line 19). Same thing for points 3, 4, 5, ... etc.
This way, it needs to assembly an Excel table like below as a result:
A B C D E F G H
1 POINT 1 POINT 2 POINT 3
2 SPEED RATIO MODULE SPEED RATIO MODULE SPEED RATIO
3 8.3333333E-02 -9.0001358E-03 9.1199364E+00 8.3333333E-02 -5.9999770E-03 9.1999509E+00 ???? ????
4 xxxxx yyyyy zzzzz xxxxx yyyyy zzzzz ???? ????
5 xxxxx yyyyy zzzzz xxxxx yyyyy zzzzz ???? ????
Any help would be appreciated. Thanks!
Ricardo
1 1 DATA PROOF SAMPLE - PROP FROM CORP D-1807 - DATA FROM PROP1 NOVEMBER 30, 2022 DATA 9/17/18 PAGE 31
2 USER-SUPPLIED ASPECT RATIO - 12/23/88
3 0 SUBCASE 1 - FMETHOD = 30 - SPEED = 1 FT/SEC SUBCASE 1
4 0 VALUES SUMMARY
5 CONFIGURATIO N = DATASG2D XY-SYMMETRY = ASYMMETRIC XZ-SYMMETRY = ASYMMETRIC
6 POINT = 1 MACH NUMBER = 0.1000 DENSITY RATIO = 8.8730E-01 METHOD = PK
7
8
9 KRATIO 1./KRATIO SPEED RATIO MODULE COMPLEX EIGENVALUE
10 125.3487 7.9777470E-03 8.3333333E-02 -9.0001358E-03 9.1199364E+00 -2.5786402E-01 5.7302250E+01
11 1 DATA PROOF SAMPLE - PROP FROM CORP D-1807 - DATA FROM PROP1 NOVEMBER 30, 2022 DATA 9/17/18 PAGE 32
12 USER-SUPPLIED ASPECT RATIO - 12/23/88
13 0 SUBCASE 1 - FMETHOD = 30 - SPEED = 1 FT/SEC SUBCASE 1
14 0 VALUES SUMMARY
15 CONFIGURATIO N = DATASG2D XY-SYMMETRY = ASYMMETRIC XZ-SYMMETRY = ASYMMETRIC
16 POINT = 2 MACH NUMBER = 0.1000 DENSITY RATIO = 8.8730E-01 METHOD = PK
17
18
19 KRATIO 1./KRATIO SPEED RATIO MODULE COMPLEX EIGENVALUE
20 126.4484 7.9083624E-03 8.3333333E-02 -5.9999770E-03 9.1999509E+00 -1.7341432E-01 5.7804996E+01
21
I need a macro to run all lines and, every time it finds a "VALUES SUMMARY" (as at line 4), it gets the value of point (after "POINT =") at line 6, and also the values of speed, ratio and module, at line 10 (under "SPEED", "RATIO" and "MODULE" respectively, at line 9). Next, it will find another "VALUES SUMMARY" at line 14, however, at this time, these data are related to point 2 (as written at line 16), and it needs to get the new value of point (after "POINT ="), and also the values of speed, ratio and module, at line 20 (under "SPEED", "RATIO" and "MODULE" respectively, at line 19). Same thing for points 3, 4, 5, ... etc.
This way, it needs to assembly an Excel table like below as a result:
A B C D E F G H
1 POINT 1 POINT 2 POINT 3
2 SPEED RATIO MODULE SPEED RATIO MODULE SPEED RATIO
3 8.3333333E-02 -9.0001358E-03 9.1199364E+00 8.3333333E-02 -5.9999770E-03 9.1999509E+00 ???? ????
4 xxxxx yyyyy zzzzz xxxxx yyyyy zzzzz ???? ????
5 xxxxx yyyyy zzzzz xxxxx yyyyy zzzzz ???? ????
Any help would be appreciated. Thanks!
Ricardo
Attachments
Last edited: