Data Files - File Format

File Formats

        When you write data to a file, you want that data to be in a format that can be read by other programs.  Programs you might use are:

        All of these programs can read the same kind of simple file.  Note, that the files we are talking about here are not typical spreadsheet files that contain formatting and formulas and other things that allow the spreadsheet to make calculations, and present your data in graphs, etc.  Those files are more complex, and are much more bloated (larger file size) that what we are talking about here.

        Here, we are talking about very simple files that contain nothing about the data.  When you are talking about simple files there are only a few considerations.

        With those considerations, then, a data file might consist of the following characters.
0
.
0
/t
2
.
1
/r
/n
0
.
1
/t
2
.
5
/r
/n
etc.

        This file would encode the data that would appear in a spreadsheet looking like this.
 
 
 

 
0.0
2.1
0.1
2.5
etc.

Notice how the data appears in this tab-delimited file.

         This pattern repeats for the rest of the data in the file.  The only thing that's not covered by this is an EOF (End-Of-File) marker that is used to indicate the end of the file.

A Note On File Sizes

      The information above can allow you to calculate or estimate file sizes.  You can compute the number of characters in a row, and multiply by the number of rows.  Here's an example.

       Assume you have data in this format:

      xx.yyy   xxxx.yy   xxxx.yy


Formatting File Data

       When you print data to a file, you usually want to control the format of the data you write.  To do that you need to know how to use format strings.  Format strings specify how data is stored.  Let's examine a few.



Problems

Links to Related Lessons
Return to Table of Contents

Send us your comments on these lessons.