File: ffe.texi

package info (click to toggle)
ffe 0.1.6-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,020 kB
  • ctags: 273
  • sloc: sh: 3,529; ansic: 2,619; makefile: 67
file content (929 lines) | stat: -rw-r--r-- 26,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
\input texinfo @c -*-texinfo-*-
@c This file uses the @command command introduced in Texinfo 4.0.
@c %**start of header
@setfilename ffe.info
@settitle ffe - flat file extractor
@finalout
@c %**end of header
@include version.texi

@copying
This file documents version @value{VERSION} of @command{ffe}, a flat file extractor. 

Copyright @copyright{} 2006 Timo Savinen

@quotation
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end quotation
@end copying

@titlepage
@title ffe
@subtitle flat file extractor
@subtitle Version @value{VERSION}, @value{UPDATED}
@author by Timo Savinen

@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@c All the nodes can be updated using the EMACS command
@c texinfo-every-node-update, which is normally bound to C-c C-u C-e.
@ifnottex
@node Top, Overview, (dir), (dir)
@top ffe

@insertcopying
@end ifnottex


@c All the menus can be updated with the EMACS command
@c texinfo-all-menus-update, which is normally bound to C-c C-u C-a.
@menu
* Overview::                    Preliminary information.
* Samples::                     Samples using @command{ffe}.
* Invoking ffe::                How to run @command{ffe}.
* ffe configuration::           How @command{ffe} works.
* Problems::                    Reporting bugs.
@end menu

@node Overview, Samples, Top, Top
@chapter Preliminary information
@cindex greetings
@cindex overview

The @command{ffe} program is a used to extract fields from flat files and to print them in different
formats. The input file structure and printing definitions are defined in a configuration file, which
is always required. Default configuration file is @file{~/.fferc}.

@command{ffe} is a command-line tool developed for GNU/linux and unix systems. @command{ffe} can read from
standard input and write to standard output, so it can be used as a part of a pipeline.


@node Samples, Invoking ffe, Overview, Top
@chapter Samples using @command{ffe}
@cindex sample

One example of using @command{ffe} for printing personnel information in xml format from fixed length flat file:

@example
$ cat personnel
john     Ripper       23
Scott    Tiger        45
Mary     Moore        41
$
@end example

@noindent
A file @file{personnel} contains three fixed length fields: @samp{FirstName}, @samp{LastName} and @samp{Age},
their respective lengths are 9,13 and 2.

@noindent
In order to print data above in xml, following configuration file must be available:

@example
$cat personnel.fferc
structure personel @{
    type fixed
    output xml
    record person @{
        field FirstName 9
        field LastName  13
        field Age 2
    @}
@}

output xml @{
    file_header "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
    data "<%n>%t</%n>\n"
    record_header "<%r>\n"
    record_trailer "</%r>\n"
    indent " "
@}
$
@end example

@noindent
Using ffe:

@example
$ffe -c personnel.fferc personnel
<?xml version="1.0" encoding="ISO-8859-1"?>
 <person>
  <FirstName>john</FirstName>
  <LastName>Ripper</LastName>
  <Age>23</Age>
 </person>
 <person>
  <FirstName>Scott</FirstName>
  <LastName>Tiger</LastName>
  <Age>45</Age>
 </person>
 <person>
  <FirstName>Mary</FirstName>
  <LastName>Moore</LastName>
  <Age>41</Age>
 </person>
$
@end example

@node Invoking ffe, ffe configuration, Samples, Top
@chapter How to run @command{ffe}
@cindex running ffe
@cindex using

@command{ffe} is a command-line tool. Normally @command{ffe} can be invoked as:

@code{ffe -o OUTPUTFILE INPUTFILE}

@noindent
@command{ffe} uses the definitions from @file{~/.fferc} and tries to guess the inputfile
structure using the first 10 000 lines or 1 MB of input data. 

@noindent
If the structure cannot be guessed the option @option{-s} must be used.

@menu
* Invocation::      Program invocation
* Configuration::   Input and printing definitions
* Guessing::        How ffe identifies input structure
* Limits::          Limitations
@end menu

@node Invocation, Configuration, , Invoking ffe
@section Program invocation
@cindex options

@noindent
The format for running the @command{ffe} program is:

@example
ffe @var{option} @dots{}
@end example

@noindent
@command{ffe} supports the following options:

@c Formatting copied from the Texinfo 4.0 manual.
@table @code
@item -c @var{file}
@itemx --configuration=@var{file}
Configuration is read from @var{file}, instead of @file{~/.fferc}.

@item -s @var{structure}
@itemx --structure=@var{structure}
Use structure @var{structure} for input file, suppresses guessing.

@item -p @var{output}
@itemx --print=@var{output}
Use output format @var{output} for printing. If not defined, then the record or structure related
output format is used. Printing can be suppressed using format @var{no}. 

@item -o @var{file}
@itemx --output=@var{file}
Write output to @var{file} instead of standard output.

@item -f @var{list}
@itemx --field-list=@var{list}
Print only fields expresses in comma separated list @var{list}. Order of fields in 
@var{list} defines also the printing order.

@item -e @var{expression}
@itemx --expression=@var{expression}
Print only those records for which the @var{expression} evaluates to true.

@item -a
@itemx --and
Expressions are combined with logical and, default is logical or.

@item -v
@itemx --invert-match
Print only those records which don't match the expression.

@item -l
@itemx --loose
Normally @command{ffe} stops when it encounteres an input line which doesn't match any of
the records in selected structure. Defining this option causes @command{ffe} continue despite the error.

@item -?
@itemx --help
Print an informative help message describing the options and then exit
successfully.

@item -V
@itemx --version
Print the version number of @command{ffe} and then exit successfully.
@end table

All remaining options are names of input files, if no input files are specified or @code{-} is given, then the standard input is read.

@subheading Expressions (option @option{-e}, @option{--expression})
Expression can be used to select specific records comparing field values. 
Expression has syntax @var{field}@strong{x}@var{value}, where @strong{x} is the comparison operator.
Expression is used to compare field's contents to @var{value} and if comparison is successfull
the record is printed. Several expressions can be defined and at least one must evaluate to true in
order to print a record. If option @option{-a} is defined all expressions must evaluate to true.

@noindent
Expressions can be defined as:

@table @var
@item field@strong{=}value
Field @var{field} is equal to @var{value}.

@item field@strong{^}value
Field @var{field} starts with @var{value}.

@item field@strong{~}value
Field @var{field} contains @var{value}.

@item field@strong{!}value
Field @var{field} is not equal to @var{value}.
@end table

@node Configuration, Guessing, Invocation, Invoking ffe
@section Configuration
@cindex configuration

@command{ffe} uses a configuration file in order to read the input file and print the output.
Default configuration file is @file{~/.fferc}.

Configuration file for @command{ffe} is a text file. The file may contain empty lines. 
Commands are case-sensitive. Comments  begin with the @code{#}-character and end at the end of the line. 
The @code{string} definitions can be enclosed in double quotation @code{"} characters. 
@code{char} is a single character. @code{string} and @code{char} can contain following escape codes: 
@code{\a}, @code{\b}, @code{\t}, @code{\n}, @code{\v}, @code{\f}, @code{\r}, @code{\"} and @code{\#}. 
A backslash can be escaped as @code{\\}.

Configuration has two main parts: the structure, which defines the input file structure and 
the output, which defines how the input data is formated for output.

@subheading Common syntax
Common syntax for configuration file is:

@example
#comment
structure @var{name} @{
    @i{option value} @dots{}
    @dots{}
    record @var{name} @{
        @i{option value} @dots{}
        @dots{}
    @}
    record @var{name} @{
        @i{option value} @dots{}
        @dots{}
    @}
    @dots{}
@}
structure @var{name} @{
    @dots{}
@}
@dots{}
output @var{name} @{
    @i{option value} @dots{}
    @dots{}
@}
output @var{name} @{
    @dots{}
@}
@dots{}
@end example

@subheading Structure
Keyword @code{structure} is used to define an input file content. An input file can contain several
types of records (or lines). E.g. file can have a header, data and trailer record types. Records
must be distinguishable from each other, this can be achieved defining different 'keys' 
(@code{id} in record definition) or having different line lengths (for fixed length structure) or different count
of fields (for separated structure) for different records.

@noindent
Typically a @code{structure} maps to a file and a @code{records} maps to a line in the file.

@noindent
A structure is defined as:
@*

@example
structure @var{name} @{
    @i{option value} @dots{}
    @dots{}
@}
@end example

@noindent
A structure can contain following options:

@table @code
@item type fixed|separated [@var{char}] [*]
The fields in the input are fixed length fields or separated by @var{char}. If * is  defined,
multiple sequential separators are considered as one. Default separator is comma.

@item quoted [@var{char}]
Fields may be quoted with char, default quotation mark is double quotation mark '"'.
A quotation mark is assumed be escaped as \@var{char} or doubling the mark as @var{charchar} in input.
Non escaped quotation marks are not preserved in output.

@item header first|all|no
Controls the occurrence of the header line. Default is no. If set as @emph{first} or @emph{all}, the first line
of the first input file is considered as header line containing the names of  the  fields. @emph{first}
means  that  only  the  first  file  has  a header, @emph{all} means means that all files have a header,
allthough the names are still taken from the the header of the first file. Header line is handled
according the record definition, meaning that the name positions, separators etc. are the same as
for fields.

@item output @var{name}
All records belonging this structure are printed according output format name.
Default is to use output named as @samp{default}.

@item record @var{name} @{@i{options} @dots{}@}
Defines one record for a structure. A structure can contain several record types.
@end table

@subheading Record
A record defines one type of input line in a file. Different records can be distinguished using 
the @code{id} option or different line lengths or field counts. 

@noindent
A record can contain following options:

@table @code
@item id @var{position} @var{string}
Identifies a record in the input file. Records are identified by the string in input record position
@var{position}. For fixed length input the position is the byte position of input record and for
separated input the position is the @var{position}'th field of the input record. Positions start from one.

A record definition can contain several id's, then all id'd must match the input line 
(@code{id}'s are @emph{anded}).

@item field @var{name}|FILLER|* [@var{length}]
Defines  one  field  in  input  structure.  length is mandatory for fixed length input structure.
Length is also used for printing the fields in fixed length format (directive @code{%D} in output definitions).
The order of fields in configuration file is essential, it defines the field order in a record.

If @emph{*} is defined instead of the name, then the @var{name} will be the ordinal number of the field,
or if the @code{header} option has value @emph{first} or @emph{all}, then the name of the field will taken from
the header line (first line of the input).

If field is named as @emph{FILLER}, the field will not appear in output.
@item fields-from @var{record}
Fields for this record are the same as for record @var{record}. @code{field} and @code{fields-from} are mutually
exclusive.
@end table

@subheading Output
Keyword @code{output} defines one output format for formatting the flat file data. Formatting
is controlled using options and printf-style directives. An output defition is allways independent
from structure, so one output format can be used with different input file formats.

Actual formatting and printing is controlled using @emph{pictures} in output options. Pictures can contain
following printf-style directives:

@table @code
@item %f
Name of the input file.
@item %s
Name of the current structure.
@item %r
Name of the current record.
@item %o
Input record number in current file.
@item %O
Input record number starting from the first file.
@item %n
Field name.
@item %t
Field contents, without leading and trailing whitespaces.
@item %d
Field contents.
@item %D
Field contents, right padded to the field length (requires length definition for the field).
@item %e
Does not print anything, causes still the "field empty" check to be performed.
Can be  used  when only the names of non-empty fields should be printed.
@item %%
Percent sign.
@end table

@noindent
Output options:
@table @code
@item file_header @var{picture}
@var{picture} is printed once before file contents.
@item file_trailer @var{picture}
@var{picture} is printed once after file contents.
@item header @var{picture}
If defined, then the header line describing the field names is printed before records.
Every field name is printed according the @var{picture} using the same separator and fields length as
defined for the fields. Picture can contain only @code{%n} directive.
@item data @var{picture}
Field contents is printed according @var{picture}.
@item separator @var{string}
All fields are terminated by @var{string}, except the last field of the record.
Default is not to print separator.
@item record_header @var{picture}
All records are started by @var{picture}. Default is not to print the record header.
@item record_trailer @var{picture} 
All records are ended with @var{picture}. Default is newline.
@item justify left|right|@var{char}
The output from the @code{data} option is left or right justified. 
@var{char} justifies output according the first occurrence of @var{char}
in the data picture. Default is left.
@item indent @var{string}
Record contents is intended by @var{string}. 
Field contents is intended by two times the string. Default is not to indent.
@item field-list @var{field1},@var{field2},@dots{}
Only fields named as @var{field1},@var{field2},@dots{} are printed, same effect as has option @option{-f}. 
Default is print all fields. Fields are also printed in the same order as they are listed.
@item no-data-print yes|no
If @code{field-list} is defined and and this is set as no and none of the fields in @code{field-list}
does not belong to the current record, then the @code{record_header} and @code{record_trailer} are not printed.
Default is yes.
@item field-empty-print yes|no
When set as no, nothing is printed for fields which consist entirely of characters from @code{empty-chars}. 
If none of the fields of a record are printed, then the printing of @code{record_trailer} is also suppressed. 
Default is yes.
@item empty-chars @var{string}
@var{string} defines a set of characters which define an "empty" field. Default is
@w{" \f\n\r\t\v"} (space, form-feed, newline, carriage return, horizontal tab and vertical tab).
@end table

@node Guessing,Limits,Configuration,Invoking ffe
@section Guessing
@cindex guess
If @option{-s} is not given, @command{ffe} tries to guess the input structure. 
@command{ffe} reads first 10 000 lines or 1 MB of input data and tries to match the structure definitions
from configuration file to input stream. If all lines match one and only one structure, the structure is used
for reading the input file.

@noindent
Guessing uses following execution cycle:

@enumerate
@item 
Input line is read
@item
All record @code{id}'s are compared to the input line, if all @code{id}'s of a record match 
the input line and the
records line length matches the total length (or total count for separated structure) of the fields,
the record is considered to match the input line. If there are no @code{id}'s, 
only the line length or field count is checked.
@item
If all lines match at least one of the records in a particular structure, the structure is considered as selected. 
There must be only one structure matching all lines used for guessing.
@end enumerate


@node Limits, , Guessing, Invoking ffe
@section Limitations
@cindex big files
@cindex limits

At least in GNU/Linux @command{ffe} should be able to handle big files (> 4 GB), other
systems are  not tested.


@node ffe configuration, Problems, Invoking ffe, Top
@chapter How @command{ffe} works
Following examples use two different input files: 
@subheading Fixed length example
Fixed length personnel file with header and trailer, line (record) is identified by the
first byte (H = Header, E = Employee, B = Boss, T = trailer).
@example
$cat personnel.fix
H2006-02-25
EJohn     Ripper       23
BScott    Tiger        45
EMary     Moore        41
ERidge    Forrester    31
T0004
$
@end example

@noindent
Structure for reading file above. Note that record @samp{boss} reuses fields from @samp{employee}.

@example
structure personel_fix @{
    type fixed
    record header @{
        id 1 H
        field type 1
        field date 10
    @}
    record employee @{
        id 1 E
        field type 1
        field FirstName 9
        field LastName  13
        field Age 2
    @}
    record boss @{
        id 1 B
        fields-from employee
    @}
    record trailer @{
        id 1 T
        field type 1
        field count 4
    @}
@}
@end example

@subheading Separated example
Sama file as above, but now separated by colon.

@example
$cat personnel.sep
H,2006-02-25
E,john,Ripper,23
B,Scott,Tiger,45
E,Mary,Moore,41
E,Ridge,Forrester,31
T,0004
$
@end example

@noindent
Structure for reading file above. Note that the field lengths are not needed in separated format.

@example
structure personel_sep @{
    type separated ,
    record header @{
        id 1 H
        field type 
        field date 
    @}
    record employee @{
        id 1 E
        field type 
        field FirstName 
        field LastName 
        field Age 
    @}
    record boss @{
        id 1 B
        fields-from employee
    @}
    record trailer @{
        id 1 T
        field type 
        field count
    @}
@}
@end example

@subheading Printing in XML-format
Data in examples above can be printed in xml using output definition like:

@example
output xml @{
    file_header "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
    data "<%n>%t</%n>\n"
    record_header "<%r>\n"
    record_trailer "</%r>\n"
    indent " "
@}
@end example

@noindent
Example output using command (assuming definitions above are saved in ~/.fferc)

@code{ffe -p xml personnel.sep}

@example
<?xml version="1.0" encoding="UTF-8"?>
 <header>
  <type>H</type>
  <date>2006-02-25</date>
 </header>
 <employee>
  <type>E</type>
  <FirstName>john</FirstName>
  <LastName>Ripper</LastName>
  <Age>23</Age>
 </employee>
 <boss>
  <type>B</type>
  <FirstName>Scott</FirstName>
  <LastName>Tiger</LastName>
  <Age>45</Age>
 </boss>
 <employee>
  <type>E</type>
  <FirstName>Mary</FirstName>
  <LastName>Moore</LastName>
  <Age>41</Age>
 </employee>
 <employee>
  <type>E</type>
  <FirstName>Ridge</FirstName>
  <LastName>Forrester</LastName>
  <Age>31</Age>
 </employee>
 <trailer>
  <type>T</type>
  <count>0004</count>
 </trailer>
@end example
@subheading Printing sql-commands
Data in examples above can be loaded to database by generated sql-commands. Note that the header and trailer
are not loaded, because only fields @samp{FirstName},@samp{LastName} and @samp{Age} are printed and @samp{no-data-print}
is set as no. This prevents the @samp{record_header} and @samp{record_trailer} to be printed for file header and trailer.

@example
output sql @{
    file_header "delete table boss;\ndelete table employee;\n"
    record_header "insert into %r values("
    data "'%t'"
    separator ","
    record_trailer ");\n"
    file_trailer "commit\nquit\n"
    no-data-print no
    field-list FirstName,LastName,Age
@}
@end example

@noindent
Output from command

@code{ffe -p sql personnel.sep}

@example
delete table boss;
delete table employee;
insert into employee values('john','Ripper','23');
insert into boss values('Scott','Tiger','45');
insert into employee values('Mary','Moore','41');
insert into employee values('Ridge','Forrester','31');
commit
quit
@end example
@subheading Human readable output
This output format shows the fields suitable for displaying in screen or printing.

@example
output nice @{
    record_header "%s - %r - %f - %o\n"
    data "%n=%t\n"
    justify =
    indent " "
@}
@end example

@noindent
Output from command

@code{ffe -p nice personnel.fix}
@example
 personel - header - personnel.fix - 1
  type=H
  date=2006-02-25
 
 personel - employee - personnel.fix - 2
       type=E
  FirstName=John
   LastName=Ripper
        Age=23
 
 personel - boss - personnel.fix - 3
       type=B
  FirstName=Scott
   LastName=Tiger
        Age=45
 
 personel - employee - personnel.fix - 4
       type=E
  FirstName=Mary
   LastName=Moore
        Age=41
 
 personel - employee - personnel.fix - 5
       type=E
  FirstName=Ridge
   LastName=Forrester
        Age=31
 
 personel - trailer - personnel.fix - 6
   type=T
  count=0004
@end example

@subheading HTML table
Personnel data can be displayed as HTML table using output like:

@example
output html @{
    file_header "<html>\n<head>\n</head>\n<body>\n<table border=\"1\">\n<tr>\n"
    header "<th>%n</th>\n"
    record_header "<tr>\n"
    data "<td>%t</td>\n"
    file_trailer "</table>\n</body>\n</html>\n"
    no-data-print no
@}
@end example

@noindent
Output from command

@code{ffe -p html -f FirstName,LastName,Age personnel.fix}
@example
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>Age</th>

<tr>
<td>John</td>
<td>Ripper</td>
<td>23</td>

<tr>
<td>Scott</td>
<td>Tiger</td>
<td>45</td>

<tr>
<td>Mary</td>
<td>Moore</td>
<td>41</td>

<tr>
<td>Ridge</td>
<td>Forrester</td>
<td>31</td>

</table>
</body>
</html>
@end example

@subheading Using expression
Printing only Scott's record using expression with previous example:

@code{ffe -p html -f FirstName,LastName,Age -e FirstName^Scott personnel.fix}
@example
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>Age</th>

<tr>
<td>Scott</td>
<td>Tiger</td>
<td>45</td>

</table>
</body>
</html>
@end example

@subheading The whole configuration file used in examples
@example
structure personel_fix @{
    type fixed
    record header @{
        id 1 H
        field type 1
        field date 10
    @}
    record employee @{
        id 1 E
        field type 1
        field FirstName 9
        field LastName  13
        field Age 2
    @}
    record boss @{
        id 1 B
        fields-from employee
    @}
    record trailer @{
        id 1 T
        field type 1
        field count 4
    @}
@}

structure personel_sep @{
    type separated ,
    record header @{
        id 1 H
        field type 
        field date 
    @}
    record employee @{
        id 1 E
        field type 
        field FirstName 
        field LastName  
        field Age 
    @}
    record boss @{
        id 1 B
        fields-from employee
    @}
        record trailer @{
        id 1 T
        field type 
        field count
    @}
@}

output xml @{
    file_header "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
    data "<%n>%t</%n>\n"
    record_header "<%r>\n"
    record_trailer "</%r>\n"
    indent " "
@}

output sql @{
    file_header "delete table boss;\ndelete table employee;\n"
    record_header "insert into %r values("
    data "'%t'"
    separator ","
    record_trailer ");\n"
    file_trailer "commit\nquit\n"
    no-data-print no
    field-list FirstName,LastName,Age
@}

output nice @{
    record_header "%s - %r - %f - %o\n"
    data "%n=%t\n"
    justify =
    indent " "
@}

output html @{
    file_header "<html>\n<head>\n</head>\n<body>\n<table border=\"1\">\n<tr>\n"
    header "<th>%n</th>\n"
    record_header "<tr>\n"
    data "<td>%t</td>\n"
    file_trailer "</table>\n</body>\n</html>\n"
    no-data-print no
@}
@end example

@subheading Using @command{ffe} to test file integrity
@command{ffe} can be used to check flat file integrity, because @command{ffe} 
checks for all lines the line length and id's for fixed length structure 
and field count and id's for separated structure.

@noindent
Integrity can be checked using command 

@code{ffe -p no -l inputfiles@dots{}}

@noindent
Because option @option{-p} has value @code{no} nothing is printed to output except the error messages.
Option @option{-l} causes all errorneous lines to be reported, not just the first one.

@noindent
Example output:

@example
ffe: Invalid input line in file 'inputfileB', line 14550
ffe: Invalid input line in file 'inputfileD', line 12
@end example

@node Problems, , ffe configuration, Top
@chapter Reporting Bugs
@cindex bugs
@cindex problems

If you find a bug in @command{ffe}, please send electronic mail to
@email{tjsa@@iki.fi}.  Include the version number, which you can find by
running @w{@samp{ffe --version}}.  Also include in your message the
output that the program produced and the output you expected.@refill

If you have other questions, comments or suggestions about
@command{ffe}, contact the author via electronic mail to
@email{tjsa@@iki.fi}.  The author will try to help you out, although he
may not have time to fix your problems.

@contents
@bye