Skip to main content
5 of 5
added 9 characters in body
ABCDEMMM
  • 1.9k
  • 1
  • 9
  • 20

How to import complex .txt file to matrix in MMA for user defined keywords / database?

I am thinking about how can we import complex .txt file (Ansys/Abaqus) to MMA for the selected database?

For example: txt file (input file):

 ...
 ...
 10894, 10895, 10896, 10897, 10898, 10899, 10900, 10901, 10902, 10903, 10904, 10905, 10906, 10907, 10908, 10909
 10910, 10911, 10912, 10913, 10914, 10915, 10916, 10917, 10918, 10919, 10920, 10921, 10922, 10923, 10924, 10925
 10926, 10927
*Edfsf, cadifd=Saoot-23, coming
 10122,  10534,      1
*Gaaf, nlau=Saoot-24
   29,   30,   31,   32,   33,   34,  400,  401,  402,  403,  404,  405,  406,  407,  408,  409
  410,  411,  412,  413,  414,  415,  416,  439,  440,  441,  442,  443,  444,  445,  446,  447
 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172
 3173, 3174, 3175, 3176, 3177, 3178
*Edfsf, cadifd=Saoot-24, coming
 1477,  1782,     1
*Gaaf, nlau=Saoot-25
   32,   33,   76,   86,  455,  456,  457,  458,  459,  460,  461,  462,  463,  464,  465,  466
 9611, 9612, 9613, 9614, 9615, 9616, 9617, 9618, 9619, 9620, 9621, 9622, 9623, 9624, 9625, 9626
 9627, 9628, 9629, 9630
*Edfsf, cadifd=Saoot-25, coming
 8891,  9060,     1
*Gaaf, nlau=Saoot-26
   24,   25,   28,   29,   30,  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,  354
  355,  356,  387,  388,  389,  390,  391,  392,  393,  394,  395,  396,  397,  398,  399,  400  
 ...
 ...

What do we need is such kind of output in MMA (matrix):

10122 10534 23
1477 1782 24
8891 9060 25  

Import rule is: we find *Edfsf line: the value after the key words Saoot- and the following line two values: namely 10122 10534 23 then we repeat the rule for the next same key words.

Sure, if I import all the data in MMA, it is ok, but how to import selected information in MMA, at least not clear for me now.

Thanks a lot for your support in advance

ABCDEMMM
  • 1.9k
  • 1
  • 9
  • 20