Editing
Guide to madagascar programs
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==sfcsv2rsf== {| class="wikitable" align="center" cellspacing="0" border="1" ! colspan="4" style="background:#ffdead;" | Convert a delimited-text ASCII file to RSF binary floating point or int. |- ! colspan="4" | sfcsv2rsf help=n delimiter=, dtype=float verb=n debug=n trunc=n o1=0. o2=0. d1=1. d2=1. unit1=unknown unit2=unknown label1=unknown label2=unknown |- | colspan="4" | Zeros will be added if number of elements is not the same in each row.<br>n1 and n2 are computed automatically. For consistency with sfdisfil and <br>sfmatmult, output is C-style order (row-first), i.e. rows in input file <br>become dimension-1 columns in output. Output encoding is native. |- | ''float '' || '''d1=1.''' || || |- | ''float '' || '''d2=1.''' || || |- | ''bool '' || '''debug=n''' || [y/n] || Extra verbosity for debugging |- | ''string '' || '''delimiter=,''' || || Separator between values in input file |- | ''string '' || '''dtype=float''' || || Input type |- | ''bool '' || '''help=n''' || [y/n] || |- | ''string '' || '''label1=unknown''' || || |- | ''string '' || '''label2=unknown''' || || |- | ''float '' || '''o1=0.''' || || |- | ''float '' || '''o2=0.''' || || |- | ''bool '' || '''trunc=n''' || [y/n] || Truncate or add zeros if nr elems in rows differs |- | ''string '' || '''unit1=unknown''' || || |- | ''string '' || '''unit2=unknown''' || || |- | ''bool '' || '''verb=n''' || [y/n] || Whether to echo n1, n2, infill/truncation |} A small usage example follows below. First, create an input file: <syntaxhighlight lang="bash"> $ echo -e '5,6,8,9.2\n11,124,5,0,1' | tee file.csv 5,6,8,9.2 11,124,5,0,1 </syntaxhighlight> You may notice that the number of values in each row is different. Run <tt>sfcsv2rsf</tt>. Notice that no options are needed. By default, zeros will be appended to make the rows equal in length: <syntaxhighlight lang="bash"> $ <file.csv sfcsv2rsf > junk.rsf ; sfdisfil < junk.rsf 0: 5 6 8 9.2 0 5: 11 124 5 0 1 </syntaxhighlight> Notice that sfdisfil displays in column order (i.e. matrix is transposed if the number of rows is right). The dimensions of the file are transposed on disk: <syntaxhighlight lang="bash"> $ sfin junk.rsf junk.rsf: in="/data/path/junk.rsf@" esize=4 type=float form=native n1=5 d1=1 o1=0 unit1="unknown" n2=2 d2=1 o2=0 unit2="unknown" 10 elements 40 bytes </syntaxhighlight> Depending on your needs, you may want to run the output through <tt>sftransp</tt>. However, if creating an input for <tt>sfmatmult</tt>, this will not be necessary, because <tt>sfmatmult</tt> is made to work with matrices that are displayed with <tt>sfdisfil</tt>, and takes as input a transpose matrix. Pipes can be used, of course, to skip the creation of intermediary files: <syntaxhighlight lang="bash"> $ <file.csv sfcsv2rsf | sfdisfil 0: 5 6 8 9.2 0 5: 11 124 5 0 1 </syntaxhighlight> Note that since this program does not need any arguments (just stdin and stdout), it will not display the man page when called with no arguments. In order to consult the automatically generated documentation, you need to pass the option <tt>help=y</tt> .
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information