CBSE Class 12 Computer Science
Question 119 of 145
File Handling — Question 15
Back to all questionsimport csv
f = open('attendees1.csv') #error 1
csv_f = csv.reader() #error 2
for row in csv_f:
print(row)- To use the
csv.reader()function, the file should be opened in read mode ('r'). - The reader object should be in syntax
<name-of-reader-object> = csv.reader(<file-handle>).
The corrected code is :
import csv
f = open('attendees1.csv', 'r')
csv_f = csv.reader(f)
for row in csv_f:
print(row)