📌  相关文章
📜  ModuleNotFoundError:没有名为“tkinter”的模块 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:42.734000             🧑  作者: Mango

代码示例4
#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')