May 2000
Beginner
761 pages
18h 20m
English
Some data, read in from tape or from a spreadsheet, may not have obvious field separators, but the data does have fixed-width columns. To preprocess this type of data, the substr function is useful. (The files in this section are found on the CD in directory chap07/OddsAnd-Ends.)
In the following example, the fields are of a fixed width, but are not separated by a field separator. The substr function is used to create fields. For gawk, see the "The FIELDWIDTHS Variable" on page 241.
% cat fixed 031291ax5633(408)987–0124 021589bg2435(415)866–1345 122490de1237(916)933–1234 010187ax3458(408)264–2546 092491bd9923(415)134–8900 112990bg4567(803)234–1456 070489qr3455(415)899–1426 % awk '{printf ... |
Read now
Unlock full access