Extracting Data

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, students will be required to extract only the valid data from different sources and formats, combining them into one cohesive output.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Convert the CSV File to a PostgreSQL Table
  1. Convert the CSV file to a PostgreSQL database table by creating a new table and loading the data from the CSV file using the copy command.
Query the Data in PostgreSQL
  1. Query the data by joining the newly created users table with the contacts table on the ID column and selecting only the rows with a valid expense code (100, 200, or 300).
Export the Query Results to a CSV File
  1. Export the valid names and email addresses to a new CSV file using the copy command.

Additional Resources

You have been tasked with extracting the name and email address of all users with a valid ExpenseCode value (100, 200, or 300). The email addresses are stored in the contacts table within the demo database. The expense codes are stored in ‘/tmp/demo.csv’.

To extract only the valid names and email addresses, you will first need to convert the CSV file to a PostgreSQL database table, by creating a new table and loading the data from the CSV file.

Next, you will need to query the data by joining the newly created users table with the contacts table on the ID column, and selecting only the rows with a valid expense code.

Lastly, you must export the valid names and email addresses to a new CSV file.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?