How to copy contents of a file to another file in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to copy contents of a file to another file in python?

How to copy contents of a file to another file in python? I want to copy contents of a 'file1' to a new 'file2'. file1 is having 3 columns and I need to copy only from 2nd row(As the first row is a header which I don't want). Also I need only 1st and 3rd column to be copied. Then I need to add 2 new rows to the new 'file2'. The 2nd row should be the index of the rows(i.e. serial number starting from 1 and so on).

31st Jul 2017, 11:03 AM
Shreya Jha
Shreya Jha - avatar
2 Answers
+ 6
What format are the files of? That information will help in choosing the best method to actually do that :)
31st Jul 2017, 11:26 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
sounds like we are supposed to do your homework ;-)
31st Jul 2017, 11:28 AM
Martin Ed
Martin Ed - avatar