Fixed Width Text File Defined

Above all, a fixed width text file is a file that has a specific format which allows for the saving of textual information/data in an organized fashion.

Fixed width text files are special cases of text files where the format is specified by column widths, pad character and left/right alignment.  Column widths are measured in units of characters. For example, if you have data in a text file where the first column always has exactly 10 characters, and the second column has exactly 5, the third has exactly 12 (and so on), this would be categorized as a fixed width text file.

To be very specific, if a text file follows the rules below it is a fixed width text file:

Below a typical fixed width text file is shown. It is specified by the following:

First column is 20 characters. It is left aligned. It is padded with spaces. It contains the NAME data within it.

Second column is 10 characters. It is left aligned. It is padded with spaces. It contains the STATE data within it.

Third column is 12 characters. It is left aligned. It is padded with spaces. It contains the TELEPHONE data within it.

So in total there are 42 characters per row:

NAME                STATE     TELEPHONE  

John Smith          WA        418-Y11-4111

Mary Hartford       CA        319-Z19-4341

Evan Nolan          IL        219-532-c301

 

If instead all three columns are right aligned it would look like this:

              Name     STATE   TELEPHONE

        John Smith        WA418-Y11-4111

     Mary Hartford        CA319-Z19-4341

        Evan Nolan        IL219-532-5301

 

Finally if in our original example we changed the alignment to right and the padding character were changed from space to the exclamation mark ! the fixed width text file would look like:

!!!!!!!!!!!!!!!!Name!!!!!STATE!!!TELEPHONE

!!!!!!!!!!John Smith!!!!!!!!WA418-Y11-4111

!!!!!!!Mary Hartford!!!!!!!!CA319-Z19-4341

!!!!!!!!!!Evan Nolan!!!!!!!!IL219-532-5301


123456789111111111122222222223333333333444

         012345678901234567890123456789012

Note: To best display a fixed width text file a fixed width font should be used (e.g. Courier).