🐍Open CSV file in Python
Reading
Use reader() to create an object for reading data from a CSV file. The reader can be used as an iterator to process the rows of the file in order.
The first argument to reader() is the source of text lines. In this case, it is a file, but any iterable is accepted (stringIO instances, lists, etc.). Other optional arguments can be given to control how the input data is parsed.
Writing
Writing CSV files is just as easy as reading them. Use writer() to create an object for writing, then iterate over the rows, using writerow() to print them.
Last updated