Main content
Computers and the Internet
Course: Computers and the Internet > Unit 2
Lesson 5: Computer filesFile types
Computers store all files as binary data, long strings of s and s. Files represent all different types of data, however—like images, videos, documents, text files, and spreadsheets. Even applications are files.
How does a computer know that one chunk of data is an image, and another chunk is a spreadsheet?
Each file has a type/kind/format, which is often reflected in its file extension. For example, "students.csv" is a "CSV Document" and has the extension "csv".
🔍 Browse around your desktop now and see what kind of files you have. If you can't see the file extensions, your computer may be setup to hide extensions by default. You can often turn extensions back on in settings. Just do a search online for "Show extensions on [your computer type]".
Detecting file types
Files don't always have an extension, and sometimes an extension doesn't reflect the actual file format. In that case, computers can try a number of techniques to figure out the file type, so that it can open that file in the most appropriate program.
One way to detect the file format is to look for clues inside the file data itself. Many file types start with a "file header" with metadata.
For example, a GIF file always starts with the letters "GIF", encoded in binary according to the ASCII standard:
0100 0111 0100 1001 0100 0110
If a computer sees that sequence of binary data, it has a high confidence that the file is a GIF and can send it to an image viewing application. The application can either successfully read and display the pixels, or let the user know that the file isn't a valid image file.
Exploring file types
Our computers load many different types of files every day. You might already be familiar with many of those file types, but you might also discover exotic new file types in your journey into computer science.
🔍 Discover more file types in the upcoming exercises. Never heard of a file? Just search for more information online with a query like "svg file format".
🙋🏽🙋🏻♀️🙋🏿♂️Do you have any questions about this topic? We'd love to answer— just ask in the questions area below!
Want to join the conversation?
- Just as a suggestion, listing different file extensions and their related definitions could help this lesson be more comprehensive. I know there is a lot of different ones, but for people who are just starting out like me, it seemed a little overwhelming.(13 votes)
- For a long time, computers have decided to hide file extensions from people.
I think this is bad because it keeps people from learning.
You might want to search for how to show file extensions for your computer.(1 vote)
- Chara, are you there?
It's your best friend...(2 votes)
- isn't an mp3 file sound based and not text based?(3 votes)
- Hi everyone!
"On any website, we can actually see a list of every file loaded by that website, and that list includes metadata like the file type. We can see that by using the "Network" tab of the Web Developer Tools".
Can anyone give me a step by step explanation on how to do that, please?(2 votes) - Why is it that file extensions are all lowercase letters?(1 vote)
- On Windows it doesn't actually matter if you're using lower- or uppercase letters for file extensions, because Windows is 'case insensitive' meaning for example the system treats the files test.txt, test.TxT, test.TXT, TEST.TXT, TeSt.TxT as if they all had the same name.
Linux systems on the other hand are case sensitive, so test.txt is something other than test.TXT.
The reason behind the convention of using lower case for file extensions is to make things easier on programmers. If you write program, ideally you know exactly how it's going to be used and what can happen. Sadly this isn't possible, because there are too many factors to consider. So you have conventions like lowercase file extensions that make life a little more predictable.
Say you write a program to open txt files, because of the convention of writing file extensions in lower case you don't need to worry about file extensions in upper- or mixedcase.(3 votes)
- would anyone like to talk about American launch codes.(2 votes)
- Mmm... no thanks. Can't let Russia have them, now can we?(1 vote)
- How is a website made of different files?(0 votes)
- You start with a html file and build your page from there. The html file points to different files and calls them to make the page look and behave the way it does.
If you want to see the source code of a site, just click Ctrl+u when you're on a webpage, that should open a window with the source code.(3 votes)
- so codecs and file formats are the same things??(1 vote)
- isn't an mp3 file sound based and not text based?(0 votes)
- Yes, mp3 is sound based file. In the exercise above, you have to reorganize tags in the example column to match with the tags in the extension column.(4 votes)
- is reddit better than youtube or facebook(0 votes)