What is CSV File in Python
A CSV (Comma Separated Values) format is one of the most simple and common ways to store tabular data. To represent a CSV file, it must be saved with the .csv file extension.
The columns are separated by a comma and there is an optional header row also which will indicate the name of each column. Python can read the CSV files using many modules like CSV module, Pandas, etc.
Reading CSV file using csv module
import csv with open("Students.csv", 'rt') as file: csv_row = csv.reader(file) for r in csv_row: print(r)
Output:
['Name', 'Age', 'Grade'] ['ABEL', '20', 'A'] ['BINDU', '21', 'A'] ['CHRISTY', '20', 'A'] ['YOUSUF', '21', 'A'] ['KRISHNA', '20', 'A']
Subscribe
Login
Please login to comment
0 Discussion