DfromLine - Creation of D-files from Line format files.

[ English | Japanese ]

[visit D-home]

SYNOPSIS

DfromLine [ options ] [ -t default-delimiter ] field-format-list [ input-file.. ]

DESCRIPTION

DfromLine converts each line of input-files into a D-record. The conversion format and field names are given by the field-format-list. See the manual of D_fmt for the detail of field-format-list.

OPTIONS

-c
enables line continuation; used with q, Q or b option of input format; switches on the line continuation. When this option is not given, the input scanner never goes beyond the newline character. When this option is given and one of the quoting options is in effect and the input scanner encounters end of the input line (newline character) it scans next input line as a part of the same record. In this case, the newline character at the end of line is converted to the character string given by -n option.
-F
adds "filename" field to each output record; value is the input file name in the form of the command arguments after globbed by the shell. This field is not added when the input file is the standard input.
-n newline-replacement
used with -c option; gives the character string to replace the the newline character. If this option is not given, the replacement is NULL string (new line character is just removed).
-t default-delimeter
gives the default delimiter for the field-format-list. Default value is TAB (control character HT).
-z default-options
gives the default options (lrqxQbf) for the field-format-list. Default value is none.
-D [i/o]datautf=8|16|32
UTF I/O feature (see manual page of UTF I/O feature.)

FIXED NAME FIELDS

filename:
at the bottom of each record, when -F is specified.

ENVIRONMENT

Ddatautf, Didatautf, Dodatautf
for UTF I/O feature.

EXAMPLES

Read name, addreess and phone-number separated by TAB character from an input file named "directory":

DfromLine name,adddress,phone-number directory

Read passwd (5) file of UNIX:

DfromLine -t ":" "username,password,uid,\
gid,gcos-field,home-dir,login-shell" /etc/passwd

Read .csv file, with field name "a", "b" and "c"

DfromLine -t "," -z q a,b,c

(assuming the first line is not for the label).

Read above .csv file, but it may have newline in data, and mark them with "@@@":

DfromLine -t , -z q -c -n @@@ a,b,c

Input:

"separated
line",B,C

Output:

a:separated@@@line
b:B
c:C

Read words and literals from c source file

DfromLine -t "[^a-zA-z0-9_]+" -z qQb -c "wd:*" *.c

Read classic FORTRAN (not Fortran77) source on IBM 80 column cards (the first column is the comment mark, the columns 2-5 are line number, column 6 is for the continuation mark, columns 7-72 for source program and columns 73-80 are for the card identification):

DfromLine "comment:(1),number:1-4r,cont:(1),source:6-71,cardno:72-79"

Read a text file as a repeating field of each character:

DfromLine "char:*" *.txt

DIAGNOSTICS

See the manual of D_msg.

SEE ALSO

Dintro, DtoLine, DfromCsv, D_fmt, D_msg.

AUTHOR

MIYAZAWA Akira


miyazawa@nii.ac.jp
2003