Suppose there is a csv file named 'example.csv':
a, b, c
a, b
a, b
a, b
a, b
I want to change all rows of this csv file to be 'a, b, c' using a Python code with csv module, however suppose that this code is heavier than my computer's computing power so, perhaps, the program may be abruptly interrupted (Probably, the user stop the program). In this case, the progress of this csv must be saved. For example, if the code did two iterations and terminated, then the original 'example.csv' or copied version 'copied_example.csv' should be:
a, b, c
a, b, c
a, b, c
a, b
a, b
You could in theory loop through the csv and save changes in every loop. Instead of using a csv module, you could use normal open() and then write() in a loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.