Downloading data from the ME 352 or NMM web sites is relatively easy. You simply click on a link and decide where to save the file. This apparent simplicity hides a little problem with file extensions for users of Microsoft Windows. This problem is an annoyance for experienced users, and a source of confusion for inexperienced users.
The problem is that depending on the steps you use to download and save the
file, Internet Explorer might add a
.txt file extension to
documents that have are stored on the web with
.m extensions. In some cases, Internet Explorer replaces
the period (dot) in
.dat with an underscore.
As a result of this undesirable behavior you must pay attention to file extensions. It is also important to realize that this is not a MATLAB error, or MATLAB's fault, or a problem with the ME 352 or NMM web sites. Yes, MATLAB may have trouble reading the file, but only because Internet Explorer has changed the file extension when it saved the file. Internet Explorer changes the file extension without telling you.
File extensions are used to indicate the content of a file and the application (software program) appropriate for working with that content. Here are some common file extensions and their conventional associations on the Microsoft Windows operating system.
The default behavior on Windows computers is that documents with the extension
in the first column will be opened by the application in the second column.
For example, double-clicking on
foo.doc will cause Microsoft Word to open
foo.doc. This automatic association of files with an appropriate application
is a good thing.
Suppose you had a folder with three files:
AltensileTest.dat file contains data in plain text format. The
PS1_solution.doc file might be the Microsoft Word document
containing your solution to Problem Set 1. The
is a MATLAB function (program). With the default settings of Windows/XP, the
list view of the folder containing those three files would look like Figure 1.
Figure 1: The default folder display option is to hide file extensions.
Note that the appearance of the folder is also affected by the view options. Select "View" >> "List" for the list view shown in this example.
The MATLAB program (
tensileTest.m) and the Word document (
in Figure 1 have icons that indicate the applications
with which they are associated. However, the file extensions are invisible. This
is the default behavior of Windows/XP. To make the file extensions visible, perform
the following steps
For our example folder containing
tensileTest.m, the folder
would now appear as in Figure 2.
Figure 2: After changing the folder display option so that file extensions are shown.
There are at least two ways of dealing with the possibility that Internet Explorer might change a file extension. The first and recommended procedure is to use the Save target as method. The second is to fix the file extension after the download. Even if you use the recommended Save target as approach, you should be aware of how to fix the extension after downloading a file.
The following steps will allow you download files with
.m extension without having to clean-up the file
The file should now be saved as a plain text document with the extension it has on the ME 352 or NMM web site.
Figure 3: Dialog box for downloading a text file with the "Save Target As" method.
The problem with file extensions occurs if you use an obvious way to download a file:
If you follow this sequence in Internet Explorer, the Save as step
causes the problem. Figure 4 shows the dialog box that Internet Explorer
presents when you select "Save As" from the "File"
menu. In particular, this is the dialog box that appears if you try to
AltensileTest.dat file from the preceding examples.
Figure 4: The Internet Explorer dialog box that results from clicking "Save As" when you are viewing a document displayed in a browser window.
Note that the title of the dialog box in Figure 4 is "Save Web Page".
Also note that the file name has been changed from
AltensileTest_dat: the period has been replaced with an underscore.
Although the user clicked on a link to a
.dat file, IE ignores the
original file extension and assumes you want to display the contents of the
browser window as an HTML document. To my knowledge, there is no graceful
way to recover other than clicking the back button and using the Save Target As
method described above.
To complete the thread of the current example, suppose that you want to save
the file anyway, even though IE thinks you want to save it as an HTML document.
The solution is to select "Text File (*.txt)" in the
"Save as type" field near the bottom of the dialog box. Doing so
in IE version 6, causes the file
AltensileTest_dat.txt to be
saved in the target directory. To make this file useful or to at least
return it to its original name you need to change the file extension in
the Windows file browser. Here are the steps:
The warning about changing file extensions is a ruse to scare inexperienced users from straying from the Microsoft fold. Figure 5 shows the warning message.
Figure 5: The warning message about changing a file extension.
If you change the file extension to one that is not currently recognized by Windows, then you will not damage the file. Rather, when you double click on that file (with the changed extension) you will get a message indicating that Windows does not know which application should be used to open the file. The only problem is that the built-in association with a particular application is lost. When you double-click on a file that is not associated with any application, windows presents you with a dialog box for choosing the application for opening the file. If you do not wish to use that dialog box, you can restore the association by changing the extension back to one that is recognized by Windows.
Note that the warning message in Figure 5 is not displayed if you change the file
.dat to one that is associated with a Microsoft
product. For example, if you change the extension from
.doc, there is no warning. There will be no complaints from Windows
because you are taking a neutral document (a plain text file) and associating it
with one of Microsoft's applications. Double-clicking on the file that used to
.dat, but now (through an extension change only) appears to be
.doc file will open the file with Microsoft Word. If you then
try to save the file from within Microsoft Word you will get further warnings
that something will be lost if you choose to save your document in a format
unfamiliar to a Microsoft application.
Clearly there is some advantage to warning users about accidental changes to their files. However, the warnings are not universal, and they are always trying to steer the user away from neutral file types and toward a proprietary and closed file types. Finally we note that this behavior does not occur on the Mozilla browser on Windows, Macintosh, and Linux, nor on Internet Explorer or the Safari browser for Macintosh. There is no technical reason why the original file extension cannot be retained when a file is opened in Internet Explorer for Windows.