Answers for "Adding column to CSV Dictreader"

0

Adding column to CSV Dictreader

01
02
03
04
05
06
07
08
09
10
# importing DictReader class  from csv module
from csv import DictReader
 
# opening csv file named as airtravel.csv
with open('airtravel.csv','r') as file:
    reader = DictReader(file,fieldnames=['Month','1958','1959','1960'])
    print("Data:")
    # printing each row of table as dictionary 
    for row in reader:
        print(row)
Posted by: Guest on January-30-2022

Python Answers by Framework

Browse Popular Code Answers by Language