Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prepend Row to CSV file.
#2
AFAIK, you will have to rewrite the file or write a new file. To rewrite, you would read the whole file into a data structure (like a list of rows), add the new row to the beginning, and then write everything back to the original file. Alternatively you could start a new file, write the new row to that file, then read each row from the new file and add it to the new file. This would be good if the file is large.

Why do you need to add it to the beginning of the file? Given how much easier it is to add to the end of the file it seems an odd way to set things up.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Prepend Row to CSV file. - by KAD_UK - Sep-24-2019, 10:03 PM
RE: Prepend Row to CSV file. - by ichabod801 - Sep-24-2019, 10:24 PM
RE: Prepend Row to CSV file. - by KAD_UK - Sep-25-2019, 07:41 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020