Extract data from file

 new new list compose Reply to this message Top page
Attachments:
+ (text/plain)

Delete this message
Author: Roger Mason
Date:  
To: txr-users
Subject: Extract data from file
Hello,

I have files like this (Si.in):

 'Si'                                       : spsymb
 'silicon'                                  : spname
  -14.0000                                  : spzn
   51196.73454                              : spmass
  0.534522E-06    2.2000   47.8169   400    : rminsp, rmt, rmaxsp, nrmt
   7                                        : nstsp
   1   0   1   2.00000    T                 : nsp, lsp, ksp, occsp, spcore
   2   0   1   2.00000    T
   2   1   1   2.00000    T
   2   1   2   4.00000    T
   3   0   1   2.00000    F
   3   1   1   1.00000    F
   3   1   2   1.00000    F
   1                                        : apword
    0.1500   0  F                           : apwe0, apwdm, apwve
   0                                        : nlx
   2                                        : nlorb
   0   2                                    : lorbl, lorbord
    0.1500   0  F                           : lorbe0, lorbdm, lorbve
    0.1500   1  F
   1   2                                    : lorbl, lorbord
    0.1500   0  F                           : lorbe0, lorbdm, lorbve
    0.1500   1  F


that I would like to extract into files like this
(Si_symb_etc.txt):

spsymb spname spzn spmass rminsp rmt rmaxsp nrmt
'Si' 'silicon' -14.0000 51196.73454 0.534522E-06 2.2000 47.8169 400

(Si_states.txt):
nsp, lsp, ksp, occsp, spcore
1 0 1 2.00000 T
2 0 1 2.00000 T
2 1 1 2.00000 T
2 1 2 4.00000 T
3 0 1 2.00000 F
3 1 1 1.00000 F
3 1 2 1.00000 F

(Si_lo.txt):
apword apwe0, apwdm, apwve nlx nlorb lorbl lorbord lorbe0 lorbdm lorbve
1 0.1500 0 F 0 2 0 2 0.1500 0 F
1 0.1500 0 F 0 2 0 2 0.1500 1 F
1 0.1500 0 F 0 2 1 2 0.1500 0 F
1 0.1500 0 F 0 2 1 2 0.1500 1 F

I am able to generate an approximation to Si_symb_etc.txt:

spsymb spname spzn spmass rminsp rmt rmaxsp nrmt
 'Si' 'silicon' -14.0000                                 51196.73454 0.534522E-06 2.2000 47.8169 400


using

@(collect)
@ (some)
@spsymb : spsymb
@spname : spname
@spzn : spzn
@spmass : spmass
@rminsp @rmt @rmaxsp @ nrmt : rminsp, rmt, rmaxsp, nrmt
@ (end)
@(end)
@(output)
spsymb spname spzn spmass rminsp rmt rmaxsp nrmt
@spsymb @spname @spzn @spmass @rminsp @rmt @rmaxsp @nrmt
@(end)

but I don't see how to remove the unwanted spaces after spzn.

For the other two outputs I don't see how to isolate the wanted parts of
the input file. I am using TXR 283.

I appreciate any help you can offer.

Thanks,
Roger