Data Cleaning and Exploration using CSV Kit

So far, we've been using the default command-line tools to clean, munge, and explore data. Tools like `wc` and `head` are useful tools but weren't designed specifically for working with datasets and are limited in many ways. These tools lack features specific to working with tabular datasets, like parsing the header row or understanding the row and column layout. Because of this, in the Data Munging Using the Command Line challenge, you had to specifically compute the number of lines in each CSV file using the `wc` tool and use that number to select just the non-header rows using the `tail` tool. You then had to repeat this for each CSV file you were trying to merge into the resulting, single file!

In this mission, we'll learn about the csvkit library, which supercharges your workflow by adding 13 new command-line tools specifically for working with CSV files. We'll focus on these five tools from csvkit:

  • csvstack: for stacking rows from multiple CSV files.
  • csvlook: renders CSV in pretty table format.
  • csvcut: for selecting specific columns from a CSV file.
  • csvstat: for calculating descriptive statistics for some or all columns.
  • csvgrep: for filtering tabular data using specific criteria.

As you work through each concept, you’ll get to apply what you’ve learned from within your browser; there's no need to use your own machine to do the exercises. The Python environment inside of this course includes answer-checking to ensure you've fully mastered each concept before learning the next.


  • Learn how to use the csvkit to clean and explore datasets

Mission Outline

1. Csvkit
2. Csvstack
3. Csvlook
4. Csvcut
5. Csvstat
6. Csvcut | csvstat
7. Csvgrep
8. Filtering out problematic rows
9. Next steps
10. Takeaways


Course Info:


The median completion time for this course is 6 hours. View Details

This course requires a basic subscription and includes four missions and one guided project. It is the ninth course in the Data Analyst in Python path and Data Scientist in Python path.


Take a Look Inside

(function(d) { d.addEventListener("DOMContentLoaded", function() { var pathname = d.location.pathname.replace(/^[/]|[/]$/g, "").replace("/", "-"); var tags = d.getElementsByTagName("iframe"); var type = pathname.startsWith("course") ? "?course=" : pathname.startsWith("path") ? "?path=" : null; if (type) { var i; for (i = 0; i < tags.length; i++) { if (tags[i].src.indexOf("signup#iframe") !== -1) { tags[i].src = tags[i].src.replace("#iframe", "") + type + pathname + "#iframe"; } } } }, false); })(document);