From the course: Advanced Hands-On Python: Working with Excel and Spreadsheet Data
The CSV format
From the course: Advanced Hands-On Python: Working with Excel and Spreadsheet Data
The CSV format
- [Instructor] One of the most common ways of working with spreadsheet data is with CSV, or comma-separated values, files. A CSV file is a simple file format for storing data in a table-like structure as a series of rows of values separated usually by commas. If you think about how a spreadsheet contains data within rows and columns, you can see how a CSV file represents the exact same data structure using plain text. Because of this simplicity, CSV files are incredibly versatile. They are a common way of transferring data between different programs, such as databases and spreadsheet applications. So let's take a look at a very simple example of a CSV file. In this case, we have some stock related data, including a ticker symbol, the name of the company, and the opening and closing price for a particular day. So each row represents a different ticker symbol and company. This is a plain text file, so you can edit it using any text editor, although usually you would use a program similar to Excel or Google Sheets or something similar. In the rest of this chapter, we're going to see how to use Python to perform basic operations on CSV files using the built-in CSV module in the standard library.
Contents
-
-
-
The CSV format1m 20s
-
Reading CSV files into an array4m 22s
-
(Locked)
Reading CSV files into a dictionary7m 14s
-
(Locked)
Reading CSV files with a filter2m 54s
-
(Locked)
Writing a CSV file2m 34s
-
(Locked)
Writing a dictionary as CSV4m 8s
-
(Locked)
Challenge: Modify CSV content2m 3s
-
(Locked)
Solution: Modify CSV content2m 59s
-
-
-
-
-