Computer Science, asked by tripathishivansh44, 8 months ago

write a function that reads a csv file and creates another csv file with same content but with different delimiter​

Answers

Answered by pooja23121979
0

Explanation:

Reading CSV Files With csv Reading from a CSV file is done using the reader object. The CSV file is opened as a text file with Python's built-in open() function, which returns a file object. This is then passed to the reader , which does the heavy lifting.

Answered by yashsozha
4

Answer:

import csv

def func():

   f = open(input("Enter the file to copy from:"),'r')

   a = input("Enter a filename to copy to:")

   fc = open(a,'w')

   w = csv.writer(fc,delimiter='|')

   lst = []

   d = csv.reader(f)

   for r in d:

       lst.append(r)

   f.close()

   w.writerows(lst)

   fc.close()

   with open(a) as f:

       d = csv.reader(f)

       for r in d:

           print(r)

func()

Explanation:

when prompted to give file name also write the respective extension like .csv

Similar questions