Professional Documents
Culture Documents
Length bytes
06 59 65 61 6B 75 73 04 42 69 6C 6C 08 31 32 33 20 50 69 6E 64
Separate fields with a delimiter
Use a special character not used in data
space, comma, tab
Also special ASCII char’s: Field Separator (fs) 1C
Here we use “|”
Also need a end of record delimiter: “#”
“Yeakus|Bill|123 Pine|Utica|OH|43050#“
Include keyword expression
Keywords label each fields
A self-describing structure
“LAST=Yeakus|FIRST=Bill|ADDRESS=123 Pine|
CITY=Utica|STATE=OH|ZIP=43050#“
Optional Fields
Fixed length
Leave blank
Field length
zero length field
Delimiter
Adjacent delimiters
Keywords
Just leave out
Reading a stream of fields
Need to break record into fields
Fixed length can simply be read into record
structure
Others must be “parsed” with a parse
algorithm
Record Structures
How do we organize records in a file?
Records can be fixed length or variable
length
Fixed length allows simple direct access lookup
Fixed may waste space
Variable - how do we find a records position?
Record Structures
Fixed Length Records
Fixed number of fields in records
Variable length
prefix each record with a length
Use a second file to keep track of record start
positions
Place delimiter between records
Fixed Length Records
All records same length
Record positions can be calculated for direct
access reads.
Does not imply the that the sizes or number
of fields are fixed.
Variable length records would lead to unused
space.
Fixed number of fields in records
No direct access
10 10 15 15 2 9
last first address city state zip