📅  最后修改于: 2022-03-11 15:04:40.994000             🧑  作者: Mango
#Importting csv module
import csv
#csv file name
filename= "aapi.csv"
# intiliaze titles and rows
fields =0
rows = 0
# reading csv file
with open(filename,'r') as csvfile:
# extract each data row one by one
csvreader=csv.reader(csvfile)
rows.append(rows)
# get total no of rwos
print("Total no of rows:%d%(csvreader.line_num)")
# print fields name
print('Field names are:' + ', '.join(field for field in fields))
# print first 5 rows
print('\n First 5 rows are:\n')
for row in rows[:5]:
# parsing each column of rows
for col in row:
print("%10s"%col),
print('\n')