From the course: Python: Working with Files

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Read CSV files in Python with csv module and pandas

Read CSV files in Python with csv module and pandas - Python Tutorial

From the course: Python: Working with Files

Read CSV files in Python with csv module and pandas

- [Instructor] Sometimes the data you're working with will be in a CSV format. Python provides a few different ways to pull out the necessary information and manipulate it as needed. One option is to use the CSV Module. Working with the CSV file is pretty similar to working with a regular text file. We can open the file as usual, but we'll read it in a different way. We'll use the CSV Module to create a reader object. We'll give it the file as well as the delimiter which will be a comma. This is a comma-separated values file. Then we'll iterate through the reader. For each row, we'll print out the monster name. The monster name is in the second column so that would be a index one. One the first iteration, this will print out the word monsterName because that's what's on the first row, the column name. On the second iteration, it will print out the first monster's name and it will continue to print out the monster names…

Contents