This document discusses working with CSV files in Google Colab using Python. It explains that CSV files store tabular data with each line as a record and fields separated by commas. The csv module can be used to read CSV files. It shows how to import a CSV file from Google Drive, use csv.reader to iterate over rows as lists, and csv.DictReader to read rows as dictionaries. Examples are given to count students by age, gender, and find parent education status from the CSV data.
12. Impost csv library
Open the csv file which is available in your Google Drive by specifying exact
path.
For Example:
import csv
csv_file = open('/content/drive/MyDrive/Colab Noteb
ooks/Datasets/student_data.csv')
13.
14. Working with csv files in Python
What is a CSV ?
CSV (Comma Separated Values) is a simple file format used to store tabular data, such as a
spreadsheet or database.
A CSV file stores tabular data (numbers and text) in plain text.
Each line of the file is a data record. Each record consists of one or more fields, separated by
commas.
The use of the comma as a field separator is the source of the name for this file format.
For working CSV files in python, there is an inbuilt module called csv.
18. Using next()
Return the next row of the reader’s iterable object as a list
(if the object was returned from reader()) or a dict (if it is a DictReader instance
Usually you should call this as next(reader).
19. We can also you use DictReader() to read CSV files as Dictionary.