TFQA: Tools for Quantitative Archaeology - Statistical Analysis Software for Archaeology TFQA
TFQA Logo

TFQA: Tools for Quantitative Archaeology
     kintigh@tfqa.com   +1 (505) 395-7979

TFQA Home
TFQA Documentation
TFQA Orders
Kintigh (ASU Directory)


MVC: Extract Fields from Fixed Format Records

      MVC is a utility that is used to extract and copy fields in single-line fixed format records. A fixed format record is one in which specific sets of adjacent column positions on each line (known as fields) contain specific categories of data. In order to use a fixed format data set with some analytical programs, it may be necessary to rearrange or reorder the fields in the records. For example, if one has a file with several fields that are not separated by spaces, one might wish to select only the X and Y coordinates and write them out separated by spaces for input into a free format analysis program. Alternately, if one has a large formatted table in a document and decides that it would be clearer if the order of the columns was changed, MVC could be used to modify the table (Note: some of the more elaborate word processing programs, e.g. Word Perfect, will do this). This program is modeled after the *MVC utility on the University of Michigan's mainframe MTS operating system.

      The program is fully interactive and is quite easy to run. The only limitations are that the lines in the input files must not have more than 1024 characters and that the input and output file names be different. Because the program defines fields based on their column positions in the line, files with embedded tab characters will generally not be processed in the expected way; in this case, MVC should be run on the output of the UNTAB program run on the input file. For each ten lines processed, the program displays a period on the screen (so you know that it is not dead). When the program ends it tells you how many records were processed and the total time elapsed.


RUNNING MVC

      To start MVC simply type MVC<Enter>. For more information on program prompts see the section: "Program Conventions." The program will respond with:


MVC: Utility to Move Fields in Fixed Length Records
Input File Name {.TXT} ?

      Give the input file name, the name of the original data file, and the output file name, the file where the new records will be written. (Full path names with drive specifications can be given).

      Next, you need to specify the fields (sets of columns) that you want copied from the input records to the output records. Although the input record may have a large number of logically distinct fields, you can copy as few or as many arbitrary sets of columns as you like. For each fields that you want to copy, the program asks:


Field ?
  Input Column ?
  Field Length ?
  Output Column ?

      To the first of these prompts you reply the starting position of the field on the input record (counting from 1 as the first position). To the second prompt you give the length. To the final prompt, you give the position (again with a 1 origin) where you want the data placed on the output record. The length of the field on the output record is the same as it is in the input record. Thus if you reply 5, 6, and 1, respectively to these prompts, columns 5 through 10 (5 for a length of 6) on the input record are written to columns 1 through 6 on the output record.


Copy Another Field ?

      If you want to copy another field, reply Y to this prompt. The program will then ask you to define the second field in the same way that you did the first. Otherwise, reply N to begin processing the records.

      Usually, several input fields are given, and it is important to keep in mind that the program does all operations in the order in which you specify them. Any positions in the output record that are not explicitly filled with data from an input field are left as blanks. Following the previous example, if for the second input filed you reply 10, 4, and 4, then input columns 10 through 13 are copied to output columns 4 through 7, thus replacing the data placed in columns 4 through 6 by the first field transfer. Note also that the same input column may appear more than once, so an input field can be copied to more than one place on an output record.


INPUT FILE

D1236 2  8.6 10.7   9 #whole 
B1834 3 17.2 18.6  11  
A1879 2 12.2  9.0  32 #reconstructed 
C1997 4  1.2  7.9   9 
    ^    ^    ^    ^    ^    ^    ^    ^ 
Col:5   10   15   20   25   30   35   40

PROMPTS

Field 1
  Input Column  ? 9
  Field Length  ? 9
  Output Column ? 1
Copy Another Field {N} ? Y
Field 2
  Input Column  ? 7
  Field Length  ? 1
  Output Column ? 11
Copy Another Field {N} ? Y
Field 3
  Input Column  ? 20
  Field Length  ? 2
  Output Column ? 13
Copy Another Field {N} ? Y
Field 4
  Input Column  ? 1
  Field Length  ? 5
  Output Column ? 16
Copy Another Field {N} ?

OUTPUT FILE

 8.6 10.7 2  9 D1236 
17.2 18.6 3 11 B1834 
12.2  9.0 2 32 A1879 
 1.2  7.9 4  9 C1997 
    ^    ^    ^    ^    ^    ^    ^    ^
Col:5   10   15   20   25   30   35   40

Page Last Updated: 17 October 2020

Home Top Overview Ordering Documentation