Guide to RSF format |
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.3Converting 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 elementsFor 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.3You 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.3An 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