From the course: Advanced Hands-On Python: Working with Excel and Spreadsheet Data

Unlock the full course today

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

Reading CSV and Excel data

Reading CSV and Excel data

- [Instructor] The Pandas Library has built-in support for reading and writing a variety of data file types. In this example, we'll see how to read Excel and CSV files. So here in my pandas_read.py file, you can see I've already imported pandas as the pd alias, and this is pretty common among Pandas users, you'll probably see this code quite a bit. That makes it easier to refer to the library. So for our first example, let's read the content of our inventory.csv file, which you can see is located right here in the same directory. So to do this, you just need to use the built-in read_csv function that Pandas provides. That's going to build and return a data frame object. So I'm going to create a variable called df for the data frame. And on pandas, I'm going to call read_csv and specify the name of Inventory.csv. And then I'm just going to print out the data frame. So the result of this function will be a filled out data frame that contains the CSV file contents. So let's go ahead and…

Contents