English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Write a Python program to read a CSV file with default delimiter comma (,). - Computer Science

Advertisements
Advertisements

Question

Write a Python program to read a CSV file with default delimiter comma (,).

Short Note

Solution

Coding:

#importing csv
import csv
#opening the csv file which is in different location with read mode with opent(‘c.\\pyprg\\samplel-csv’, ‘r’) as F:
#other way to open the file is f= (‘c:\ \ pyprg\ \ samplel.csv’, ‘r’)
reader = csv.reader(F)
# printing each line of the Data row by row
print(row)
F.close()

Output:

[‘SNO’, ‘NAME’, ‘CITY’]
[‘12101’, ‘RAM’, ‘CHENNAI’]
[‘12102′,’ LAV ANYA’,’ TIRCHY’]
[‘12103’, ‘LAKSHMAN’, ‘MADURAI’]

shaalaa.com
Read and Write a CSV File Using Python
  Is there an error in this question or solution?
Chapter 13: Python and CSV files - Evaluation [Page 266]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 13 Python and CSV files
Evaluation | Q 3. | Page 266
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×
Our website is made possible by ad-free subscriptions or displaying online advertisements to our visitors.
If you don't like ads you can support us by buying an ad-free subscription or please consider supporting us by disabling your ad blocker. Thank you.