You can use the `csv` module in Python to read from and write to CSV files, which stands for comma-separated values. Here’s a basic example to get you started:
Reading from a CSV File:
```
import csv
with open(‘file.csv’, ‘r’) as file:
reader = csv.reader(file)
for row in reader:
print(row)
```
In this example, each `row` is a list of strings where each string represents a column value.
Writing to a CSV File:
```
import csv
data = [[‘Name’, ‘Age’], [‘Alice’, 23], [‘Bob’, 22]]
with open(‘file.csv’, ‘w’, newline=’‘) as file:
writer = csv.writer(file)
writer.writerows(data)
```
In this example, `data` is a list of lists that is used to write rows to the CSV file.
Here are a few important details:
- You should always open the file with `newline=’‘` when writing to a CSV file to avoid extra newlines.
- `csv.reader` returns an iterable CSV reader object that you can loop over to access each row one by one.
- `csv.writer` provides the `writerow` method to write a single row and `writerows` to write multiple rows at once.
- For more advanced usage (such as dealing with CSV files that have a different delimiter or quote character), look at `csv.reader` and `csv.writer` documentation.