Updating CSV files
Given that CSV files are simple text files, the best solution to update their content is to read them, process them into internal Python objects, make the changes, and then overwrite the result back in the same format. In this recipe, we will see how to do this.
Getting ready
In this recipe, we will use the movies.csv
file that is available on GitHub at https://github.com/PacktPublishing/Python-Automation-Cookbook-Second-Edition/blob/master/Chapter06/movies.csv. It contains the following data:
|
|
|
225.7 |
Gone With the Wind |
1939 |
194.4 |
Star Wars |
1968... |