You are on page 1of 1

Python Programming home

Department of Computing, Imperial College London

Python for C++ Programmers


Chapter 1: Introduction
Chapter 2: Basic data types
Chapter 3: Variables and operators
Chapter 4: Sequence types
Chapter 5: Sets and dictionaries
Chapter 6: Control flow
Chapter 7: Functions
Chapter 8: Object-oriented programming
Chapter 9: Modules
Chapter 10: Files
[10.1] Handling text files
[10.2] JSON files
[10.3] Loading JSON files
[10.4] Writing to JSON files
[10.5] pickle
[10.6] Pickling time!
[10.7] CSV files
[10.8] Reading CSV files
[10.9] Reading CSV files into a dict
[10.10] Writing to CSV files
[10.11] That's a wrap!

Chapter 10: Files


>> CSV files
face Josiah Wang

Let us look at handling another file format that is quite often used: Comma Separated Value (CSV).
A CSV file is a plain text file that structures its data in tabular form. Think spreadsheets.
Generally, CSV files use a comma (,) to separate each data value (hence its name). Other delimiters can also be
used: tabs (\t), colons (:), and semi-colons (;).
The first row usually contains the name of the columns. Think of headers in tables. This is usually followed by
one record per line.
Here is an example of the content of a CSV file:
name,faculty,department
Alice Smith,Science,Chemistry
Ben Williams,Eng,EEE
Bob Jones,Science,Physics
Andrew Taylor,Eng,Computing

Previous Next 

Page designed by Josiah Wang Department of Computing | Imperial College London

You might also like