next up previous [pdf]

Next: Other documentation Up: Compatibility with other file Previous: Reading and writing SEG-Y

Reading and writing ASCII files

Reading and writing ASCII files can be accomplished with the sfdd program. For example, let us take an ASCII file with numbers

bash$ cat file.asc
1.0 1.5 3.0
4.8 9.1 7.3
Converting it to RSF is as simple as
bash$ echo in=file.asc n1=3 n2=2 data_format=ascii_float > file.rsf
bash$ sfin file.rsf
file.rsf:
    in="file.asc"
    esize=0 type=float form=ascii
    n1=3           d1=?           o1=?
    n2=2           d2=?           o2=?
        6 elements
For more efficient input/output operations, it might be advantageous to convert the data type to native binary, as follows:
bash$ echo in=file.asc n1=3 n2=2 data_format=ascii_float | \
sfdd form=native > file.rsf
bash$ sfin file.rsf
file.rsf:
    in="/tmp/file.rsf@"
    esize=4 type=float form=native
    n1=3           d1=?           o1=?
    n2=2           d2=?           o2=?
        6 elements 24 bytes

Convert from RSF to ASCII is equally simple:

bash$ sfdd form=ascii out=file.asc < file.rsf > /dev/null
bash$ cat file.asc
1 1.5 3 4.8 9.1 7.3
You can use the line= and format= parameters in sfdd to control the ASCII formatting:
bash$ sfdd form=ascii out=file.asc \
line=3 format="%3.1f " < file.rsf > /dev/null
bash$ cat file.asc
1.0 1.5 3.0
4.8 9.1 7.3
An alternative is to use sfdisfil.
bash$ sfdisfil > file.asc col=3 format="%3.1f " number=n < file.rsf
bash$ cat file.asc
1.0 1.5 3.0
4.8 9.1 7.3




2012-07-19