Solve this assignment Start Apache Airflow. Open Apache Airflow in IDE Open a terminal…
- User
Solve this assignment Start Apache Airflow. Open Apache Airflow in IDE
Open a terminal and create a directory structure for the staging area as follows: /home/project/airflow/dags/finalassignment/staging. 1 sudo mkdir -p /home/project/airflow/dags/finalassignment/staging Copied!Executed! Execute the following commands to give appropriate permission to the directories. 1 sudo chmod -R 777 /home/project/airflow/dags/finalassignment Copied!Executed! Download the data set from the source to the following destination using the curl command. 1 sudo curl https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-DB0250EN-SkillsNetwork/labs/Final%20Assignment/tolldata.tgz -o /home/project/airflow/dags/finalassignment/tolldata.tgz Copied!Executed!
Please use BashOperator for all the tasks in this assignment. Create a new file named ETL_toll_data.py in /home/project directory and open it in the file editor.
Import all the packages you need to build the DAG.
Define the DAG arguments as per the following details in the ETL_toll_data.py file:
Parameter Value owner start_date today email email_on_failure True email_on_retry True retries 1 retry_delay 5 minutes Take a screenshot of the task code. Name the screenshot dag_args.jpg.
Define the DAG in the ETL_toll_data.py file using the following details.
Parameter Value DAG id ETL_toll_data Schedule Daily once default_args As you have defined in the previous step description Apache Airflow Final Assignment Take a screenshot of the command and output you used. Name the screenshot dag_definition.jpg.
Create a task named unzip_data to unzip data. Use the data downloaded in the first part of this assignment in Set up the lab environment and uncompress it into the destination directory using tar.
Take a screenshot of the task code. Name the screenshot unzip_data.jpg.
You can locally untar and read through the file fileformats.txt to understand the column details.
Create a task named extract_data_from_csv to extract the fields Rowid, Timestamp, Anonymized Vehicle number, and Vehicle type from the vehicle-data.csv file and save them into a file named csv_data.csv.
Take a screenshot of the task code. Name the screenshot extract_data_from_csv.jpg.
Create a task named extract_data_from_tsv to extract the fields Number of axles, Tollplaza id, and Tollplaza code from the tollplaza-data.tsv file and save it into a file named tsv_data.csv.
Take a screenshot of the task code. Name the screenshot extract_data_from_tsv.jpg.
Create a task named extract_data_from_fixed_width to extract the fields Type of Payment code, and Vehicle Code from the fixed width file payment-data.txt and save it into a file named fixed_width_data.csv.
- Assistant