Q. Write a function that reads a csv file and creates another csv file with the same content, but with a different delimiter.
Answer :-
import csv def Pathwalla( file1 ): file2 = open( "Portalexpress.csv","w",newline="" ) portal_write = csv.writer( file2 , delimiter = "|") data = csv.reader(file1) for i in data : if i[0][:5] != "check" : portal_write.writerow( i ) file2.close() file1 = open( "Pathwalla.csv","r" ) Pathwalla( file1 ) print ("Thank You !!")
Content in Pathwalla.csv :-
This is Path Wall Website. check here you find all solution Tell me about you check are you fine Ok thankyou
Output :-
Thank You !!
>>>
>>>
Content in Portalexpress.csv after program running:-
This is Path Wall Website. Tell me about you Ok thankyou
The code is wrong. The question says that the new file should contain the same content except the lines starting with "Check". So there should be some sort of an if condition.
ReplyDeleteSorry, I have corrected it.
DeleteWe had to make a function(def), please correct it:)
ReplyDeleteOk.
Deletehi
ReplyDeleteHi : )
DeleteThanks for this. Helped me alot during my exams.
ReplyDeleteWelcome : ) and All the best.
DeleteWelcome : )
ReplyDeletePLS MAKE IT SMALLER
ReplyDeleteDEFINITELY NO
DeletePLS MAKE IT SMALLER
ReplyDeleteHI I AM GIRIJA
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )