Q. What is the output of the following considering the file data.csv given on the right
File data.csv contains:
Identifier; First name; Last name
901242; Riya; Verma
207074; Laura; Grey
408129; Ali; Baig
934600; Manit; Kaur
507916; Jiva; Jain
import csv
with open('C:\data.csv','r+') as f:
data = csv.reader(f)
for row in data:
if 'the' in row:
print(row)
Answer =
It will not give any output, because data.csv did not contain “the” word.
Hello! The above file might give an error as the absolute path contains single backslashes (\) which are treated as escape sequences. The corrected code should be:
ReplyDeletewith open('C:\\data.csv','r+') as f:
I have created data.csv file at given location.
DeleteThe above file might give an error as the absolute path contains single backslashes (\) which are treated as escape sequences. The corrected code should be:
ReplyDeletewith open('C:\\data.csv','r+') as f:
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )