.ig >>
![]() Tabular data handling toolkit |
.>> .TH fldfmt(1) TDH "19-SEP-2003 TDH scg@jax.org" .SH NAME fldfmt(1) \- take a tabular data stream and format, add new field, or modify a field .ig >> .>> .SH SYNOPSIS \fCfldfmt [\fIoptions\fC] [\fIformatstring\fC] .ig >> .>> .SH DESCRIPTION \fBfldfmt\fR is a filter utility that selects fields from a stream of records and outputs them to standard output. It can be used to build human-presentable reports, or to process data. Data records should be white-space delimited, tabular ascii format. One output record is produced for every input record. Use it in one of these modes: .LP \fBformat mode:\fR Create formatted rows. Fields will be presented as specified in a \fIformatstring\fR argument (or format file when \fC-f\fR is used). This is the default mode. You'll probably want to also use \fC-dp\fR for data processing purposes. .LP \fBnew field mode:\fR all fields will be output, along with one new field. See \fC-newfield\fR below .LP \fBmodify field mode:\fR all fields will be output, with one of them changed to a constant value. See \fC-modfield\fR below .ig >> .>> .SH FORMAT MODE .LP \fIformatstring\fR (or the format file) may contain data field @names or field @numbers as in the examples below. .ig >> .>> \0Inline formatting codes .ig >> .>> , all of which begin with colon (:) may also be used. Everything else in \fIformatstring\fR is passed through transparently. .LP \fIformatstring\fR may actually be up to 3 command line arguments, which \fBfldfmt\fR will concatenate together. This allows long formatstrings to be split up for readability. .ig >> .>> .SH OPTIONS .LP \fB-h\fR .IP \0 Header mode. Data field names are expected in the first non-comment non-blank line, separated by white space. The \fIformatstring\fR can then access fields by @name, instead of just by @number. .ig >> .>> .LP \fB-t\fR .IP \0 Input fields expected to be tab-delimited. With \fC-newfield\fR or \fC-modfield\fR, output fields will also be tab-delimited. .ig >> .>> .LP \fB-f \fIformatfile\fR .IP \0 Output format specification will be taken from \fIformatfile\fR instead of the command line; same syntax expected. Upper limit of 3000 characters. .ig >> .>> .LP \fB-dp\fR .IP \0 Data processing mode. Equivalent to \fC-u -c\fR. This is normally what is desired when doing data processing, ie. when the output is not for presentation to humans. .ig >> .>> .LP \fB-u\fR .IP \0 Show embedded underscores found in data fields. Normally they are converted to spaces. Underscore conversion may also be controlled within \fIformatstring\fR using inline formatting codes \fC:u+\fR and \fC:u-\fR. .ig >> .>> .LP \fB-c\fR .IP \0 Show nulls literally. Normally nulls are displayed as a zero length string. Null representation may be controlled from the .ig >> .>> \0project config file. .ig >> .>> .ig >> .>> .LP \fB-newfield \fIfieldpos# contents\fR .IP \0 Output all fields, and add a new field at position \fIfieldpos#\fR containing \fIcontents\fR. Implies \fC-dp\fR. No \fCformatstring\fR is accepted. Example: to add a new field containing \fCabc\fR at the beginning of each output record use \fCfldfmt -newfield 1 "abc"\fR .ig >> .>> .LP \fB-modfield \fIfieldpos# contents\fR .IP \0 Output all fields, and modify the field at position \fIfieldpos#\fR so that it will contain \fIcontents\fR. Implies \fC-dp\fR. No \fCformatstring\fR is accepted. Example: to change the 3rd field such that it contains \fCabc\fR on each output record, use \fCfldfmt -modfield 3 "abc"\fR .ig >> .>> .LP \fB-l\fR .IP \0 Turn off evaluation of .ig >> .>> \0inline formatting codes .ig >> .>> .ig >> .>> .LP \fB-s\fR .IP \0 Suppress data-less lines. For lines that contain at least one variable, and that had all variables evaluate to "" (nothing), the entire line is suppressed. If \fIformat\fR is more than one line, individual lines are handled separately. .ig >> .>> .LP \fB-bh\fR .IP \0 Output a bogus field name header as the first output line. May be useful in situations where a header line is expected but not used. .ig >> .>> .SH EXAMPLES .LP \fCcat mydata | fldfmt "@1 (@2)" .LP \fCcat mydata | fldfmt "@1 @2 :dec28 @4"\fR .LP \fCcat scores | fldfmt -h "Name: @firstname @lastname :col40 Score: @score"\fR .LP \fCcat scores | fldfmt -newfield 3 "="\fR .LP \fCcat scores | fldfmt -modfield 6 "d"\fR .LP The following example makes html table rows containing hyperlinks. Assumes that CGIPROG is defined to the URL of the CGI executable using varvalue in the tdh config file. .nf fldfmt " | @fname @lname | " .fi .ig >>
![]() Tabular data handling toolkit Copyright Steve Grubb |