I. Text file

The term "text file" or "text-only file" often comes up when you need to exchange data or files with other people. Other common terms for the same type of file are "unformatted file" and "ASCII (pronounced a-s-key) file." A good understanding of what a text file is greatly improves your ability to manipulate files and data across different programs and across different computers.

A text file is a file which does not have any formatting information. Formatting information includes information about font face, font size, font effect, indentation, paragraph margin, line spacing, tab locations, styles, etc. (Returns, which appear as paragraph marks, are not part of formatting.) A text file can contain numbers. In fact, a text file may only contain numbers. Thus, the word "text" in "text file" should not be interpreted as "letters."

When you save a file created and edited by a word processing program, formatting information is simultaneously saved as part of the file. The file contains both the text itself and the formatting information coded specifically by the particular program. Thus, these files are typically called with the name of the program such as "MS-Word file" and "Word Perfect file." This type of file can only be opened by the same program, unless the other program has a built-in file conversion utility or you use a separate translation utility program. If you save the same file as a text file, you will loose the formatting information, however, the file becomes readable by many other programs on different computers such as DOS, Windows, Macintosh, and UNIX. This is why a text file is very useful when you need to read the content of a file in other programs or on other computers.

Saving a file as a text file is simple. As you try to save a file, a word processing program provides an option which determines the file type. The option should read something like "Save File as Type." This option should give you a list of file types that you can save a file in, one of which is "Text" or "Text only." (See Figure 4.1.)

Figure 4.1


Since you lose all of the formatting, effects such as bold letters, centered paragraphs and large fonts will be gone. Figure 4.2 illustrated the difference between a formatted file and a text file. Returns and tab keys are part of text, so they will remain in the text file although information about specific tab locations are gone.

Figure 4.2

        < Download Ch4fmd.doc (Microsoft Word Document) >


       

A text file can be generated not only by a word processing program, but also by other programs such as a spread sheet program. For example, an Excel worksheet shown in Figure 4.3 can be saved as a text file.

Figure 4.3

        < Download Ch4excl.xls (Microsoft Excel Worksheet) >

 

       

Figure 4.4 shows a dialogue box as you save a file in MS-Excel. You choose "Text (Tab delimited)" and save the file.

Figure 4.4


After you save the spread sheet file as a text file, you can open it using any word processing program of any version. Figure 4.5 shows the same text file opened in MS-Word. As you can see, tab keys have been inserted between cells and a return key appears at the end of each line. Since the file does not have any tab locations, the numbers are not properly aligned. Once two tab locations are specified, the content looks fine as shown in Figure 4.6.

Figure 4.5


 

Figure 4.6

 

Once saved in a text file, the content can be transferred to other programs and to other computers. A solid understanding of text file and the difference between formatted files and text files will not only give you another skill, but also it will bring you a sense of power over the software programs. You should start feeling you are actually manipulating the programs.

If you are planning to conduct a statistical analysis using a package such as SPSS or SAS on a main frame computer, being able to handle data using a spread sheet program will prove very useful. Putting data into a good shape for the statistical package is a lot easier to perform on a personal computer than on a main frame computer. Once you put the data in a required format, you can save it in a text file for uploading it to your main frame computer. (We will discuss uploading in a later chapter.)

 

II. Exchanging data and files

Exchanging of data and files is classified into two types, namely across different software on the same computer or on different computers. In this section, the focus is on the exchanges of data and files stored on floppy disks using personal computers, namely Windows and Macintosh. The exchange using Internet will be discussed later.

Exchange of data and files on the same computer has become fairly straightforward. There are five ways to accomplish the exchange.

  1. Open-file. You might simply be able to open a formatted file in another program. (Many software programs contain built-in conversion utility so that users can use files in a variety of format.)

  2. Copy-&-paste. You highlight the part you want and issue the copy command and paste it in the other program.

  3. Save-as: You save the file in the other program’s format. Use the save-file-type-as option.

  4. Save-as-text: If the target program is not on the list for save-file-type-as, you can always use the text-file option (though you will lose the format.)

  5. Separate conversion utility. There are commercial packages available for translating files from one type to another.

 

Exchanges across computers add another step for the handling of floppy disks. After this additional step, the rest of the process is essentially identical to exchanging files on the same computer.

In order to read and write data on a floppy disk, it must first be formatted or initialized by a computer. This process of "formatting" or "initialization" is similar to building streets on an uncharted plain field and creating an address system so that people can go to specific places. A computer needs an address system to safely store data in unoccupied space on a floppy disk. Windows and Macintosh, unfortunately, use different address systems. This is why floppy disks are unreadable by the other machine. A good news is that recent models of Macintosh can read and write data on floppy disks formatted by Windows. MacOpener by DATAVIZ is a software program that allows you to open Macintosh disks and files on a Windows machine. Thus, for now, if you have access to a recent Macintosh, you should be able to save your data or files onto a floppy disk formatted for Windows. Once you passed this stage, you can use one of the last three methods listed above.

Exchanging of data and files has an endless number of possibilities, and each situation might be slightly different. Thus, experience counts a lot. Do not give up when a situation arises, explore different options.

 

Exercises for Chapter 4

  1. Go through the steps discussed above a few times until you feel very comfortable going back and forth between a word processing program and a spread sheet program.

  2. MS-Excel has other options under "Save File as Type". Save an Excel worksheet in "Formatted Text (Space delimited)" and "CSV (Comma delimited)." Then, open the files using MS-Word or any other word processing programs. Observe how they are different from the "Text (Tab delimited)" option. Do you think they can be classified as text files? What is your criteria for your answer?

  3. Exchange data and file with your colleague.

    1. Get hold of a person who uses the same type of computer (Windows or Macintosh) but uses a different software for word processing. Try exchanging files between the two. Find out if you can exchange formatted files or if you have to save files as text files.

    2. Get hold of a person who uses a different type of computer for word processing and spread sheet. Try exchanging word processing files and spread sheet files between the two of you.

  4. An MS-Word file is given to you by your friend who does not know much about formatting. When you open the file, you find it looking like the one shown in Figure 4.7. Your friend wants to add another column for average scores of the two tests. You recognize the computation is better to do using Excel. You would like to read the file in Excel, but the present form is not good for Excel.

    1. Manipulate the text using the replace function so that you can open the file in Excel.

    2. Compute the average of two numbers for each person, put the result in the third column in Excel, and sort according to the average score (highest to lowest).

    3. Finally, create a MS-Word file so that you friend can see the file looking like the one shown in Figure 4.8.

      Figure 4.7


    4.  

      Figure 4.8

        1. < Download Ch4ex4.doc (Microsoft Word Document) >


    5.  

  5. (Exercise for people who need to perform statistical analysis) Figure 4.9 shows an Excel worksheet for the data from an experiment. The experiment has two independent variables, one with two levels and the other with three levels, and one dependent variable. The design calls for a 2X3 ANOVA. A statistical package requires the data to be in the format shown in Figure 4.10. Convert the Excel worksheet (Figure 4.9) to a text file (Figure 4.10).

    Figure 4.9

          < Download Ch4ex5.xls (Microsoft Excel Worksheet) >


  6. Figure 4.10


    1.