Reading and Writing CSV Files in Python with Pandas

python_tutorials

There are many ways of reading and writing CSV files in Python. There are a few different methods, for example, you can use Python’s built in open() function to read the CSV (Comma Separated Values) files or you can use Python’s dedicated csv module to read and write CSV files. Depending on your use-case, you can also use Python’s Pandas library to read and write CSV files.

In this article, you will see how to use Python’s Pandas library to read and write CSV files. However, before that let’s briefly see what a CSV file is.

What is a CSV File?

A CSV file is nothing more than a simple text file. However, it is the most common, simple, and easiest method to store tabular data. This particular format arranges tables by following a specific structure divided into rows and columns. It is these rows and columns that contain your data. A new line terminates each row to start the next row. Similarly, a comma, also known as the delimiter, separates columns within each row.

Take the following table as an example:

| City         | State        |

To finish reading, please visit source site