CSV editing in Python
For reading and writing a CSV file in Python, it is best to take advantage of the csv reader and writer classes that's built in.
This script reads in a file called 'myDataFile.csv' into the csv.reader() object and sets up the sets up the csv.writer() object to write to the tempFile.
Rows of csv data are read one-by-one as a list where you can edit each data member in the for loop.
Then, the edited row can be placed in the tempFile.
Finally the tempFile is moved, similar to the command line 'mv' command, and will overwrite 'myDataFile.csv'
Hope this helps!
Rows of csv data are read one-by-one as a list where you can edit each data member in the for loop.
Then, the edited row can be placed in the tempFile.
Finally the tempFile is moved, similar to the command line 'mv' command, and will overwrite 'myDataFile.csv'
Hope this helps!