Why a CSV File
A lot of the data you meet is a table — marks, attendance, a price list, a bank statement. A CSV file is one of the most popular ways of keeping a table like that in a plain text file, and it is popular for one reason: almost every program on earth can read one.
1Tabular data
Tabular data is data arranged in rows and columns. Each row is one record — one student, one item, one payment — and every record has the same columns as every other one.
| Roll | Name | Marks |
|---|---|---|
| 1 | Ravi | 78 |
| 2 | Meera | 91 |
| 3 | Amit | 65 |
You have seen this shape drawn as a grid all your life — in Excel, on a report card, on the board. But a grid is a picture of the data. A file cannot store lines and boxes. It stores characters, one after another, so a table has to be written down some other way.
2The same table, written down
A CSV file writes it like this: one line for each row, and inside a line, a comma between the values.
| Roll | Name | Marks |
|---|---|---|
| 1 | Ravi | 78 |
| 2 | Meera | 91 |
| 3 | Amit | 65 |
Four lines. The highlighted commas are the only thing marking where one column ends and the next begins.
That is the whole idea. The columns are not stored anywhere — they are worked out by counting commas. Line one has two commas, so it has three values, so the table has three columns.
3The first line is usually the header
Look at the first line again: Roll,Name,Marks. Those are not a student — they are the column names. A line like that at the top of the file is called the header, and it is what lets a person open the file and know what the numbers mean.
Roll,Name,Marks
1,Ravi,78
2,Meera,91
3,Amit,654The file must be named .csv
A CSV file is saved with the extension .csv — marks.csv, students.csv, sales_2025.csv. That extension is how the rest of your computer knows what the file is: double-click a .csv and Excel opens it as a grid, while the same file named marks.txt opens in Notepad as four lines of text.
marks.csvExcel, Google Sheets and Python all recognise it as a table.
marks.txtExactly the same characters inside — but nothing treats it as a table.
.csv, and it will behave like a CSV everywhere.5It is still a text file
Open marks.csv in Notepad and you can read every character of it. There is nothing hidden, nothing encoded, no special format — which is exactly why so many different programs can read one. A CSV is an ordinary text file that follows one extra rule about where the commas go.
.csv is a text file — just values and commas. An .xlsx is a binary file, and it has to be, because it also stores formulas, colours, fonts, charts and several sheets. A CSV can hold none of those. It holds values, and that is the trade: it loses the formatting and gains the ability to be opened by anything.6The three, side by side
You now know three ways of putting data in a file. Each is good at something different, and the exam likes asking which you would choose:
| Text file | Binary file | CSV file | |
|---|---|---|---|
| What it holds | any text at all | raw bytes | a table |
| Readable in Notepad | yes | no | yes |
| Opens in Excel | no | no | yes |
| Readable by other programs | yes | only the one that wrote it | yes |
| Numbers come back as | text | numbers | text |
| Best for | notes, logs, paragraphs | one program's own private data | tables shared with anything |
78 and "78", exactly as a text file does — because it is a text file. A binary file is still the only one of the three that gives a number back as a number. What CSV buys with that loss is that everybody else can open the file.7Where you actually meet CSV files
Every school management system exports a class list as CSV, because every other program can read one.
Download a statement and you are usually offered PDF or CSV. The CSV is the one you can total up yourself.
Excel writes it, Python reads it, a website loads it. CSV is the common language none of them owns.
pd.read_csv() is how almost every data project starts — including the ones in the IP course.
8Recap
One of the most popular ways of keeping tabular data in a text file.
And inside the line, a comma between each pair of values.
Two commas mean three values. Nothing in the file names the columns except the header line.
The column names. It is an ordinary line, so your program has to remember it is there.
The extension is how Excel, Python and everything else recognise the file as a table.
Readable in Notepad, character for character. Not a third kind of file — a text file with one extra rule.
What does CSV stand for?
A CSV file is which kind of file?
A line in a CSV file reads 4,Sneha,88. How many columns does the table have?
What extension should a CSV file be saved with?