Computer Science - Class 12
Chapter 2 - File Handling in Python

Explain Reading CSV files with CSV.

 

Answer:

CSV files are handled using the csv module. The reader class from the module is used for reading from a csv file .

  • At first, the csv file is opened in the read mode using the in-built function open( ).
  • The open( ) function returns a file object.
  • This file object is passed to the reader.

Example:

import csv

f=open( "values.csv" , 'r' )

output=csv.reader(f,delimiter= ',' )

for row in output:

    print(row)

 

 

 

Learn in your speed, with individual attention - Teachoo Maths 1-on-1 Class

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 13 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.