Writing a CSV File
Writing a CSV file in python
We'll cover the following...
We'll cover the following...
The csv module also has two methods that you can use to write a CSV file. You can use the writer function or the DictWriter class. We’ll look at both of these as well. We will be with the writer function. Let’s look at a simple example:
In the code above, we create a csv_writer function that accepts two arguments: data and path. The data is a list of lists that we create at the bottom of the script. We use a shortened version of the data from the previous example and split the strings on the comma. This returns a list. So we end up with a nested list that looks like this:
The csv_writer function opens the path that we pass in and ...