To write a python program for reading content from a CSV file.
- Hardware โ PCs
- Anaconda โ Python 3.7 Installation / Google collab
Import pandas as pd.
Read the CSV file using read_csv method.
Use head and tail method to get the required contents from the file.
Use len() method to get the number of rows and columns.
Display the result.
# Program to read contents from csv file
#Developed by: HARITHA RAMESH
#Reference Number: 23003324
import pandas as pd
df = pd.read_csv('nba.csv')
print(df.head(10))
print(df.tail())
print("Number of rows:",len(df.axes[0]))
print("Number of columns:",len(df.axes[1]))
Thus python program for reading content from a CSV file is successful.