Answer to Question #231133 in Python for Shreya

Question #231133
write read csv() and write csv() function which read and write in a csv file. The file name passed
as parameter.
1
Expert's answer
2021-09-06T07:05:08-0400
import csv


def read(file1):
    with open(file1, 'r') as file:
        rd = csv.reader(file)
        for r in rd:
            print(r)
def write(file2):
    with open(file2, 'w', newline='') as file:
        w= csv.writer(file)
        w.writerow(["1", "2", "3"])
        w.writerow([1, "4", "5"])
        w.writerow([2, "6", "7"])


f1="input.csv"
f2="output.csv"


read(f1)
write(f2)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS