Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Monday, November 23, 2020

Python program perform read operation with .csv file by G Krishna Chauhan

Source Code


# Program type 1

import csv

f=open('dnnmais.csv', 'r')

reader = csv.reader(f)  

for row in reader:

    print(row)

f.close


# Program type 2

import csv

with open('dnnmais.csv', 'r') as file:

    reader = csv.reader(file)  

    for row in reader:

        print(row)


# Program type 3

import csv

with open('krishna.csv', 'r') as file:

    reader = csv.reader(file,delimiter = '\t')  

    for row in reader:

        print(row)



OUTPUT

['Name', 'Class', 'Roll No']
['G krishna', 'M.Tech', '1001910503']

No comments:

Post a Comment