Icon

01_​Access_​data_​from_​NoSQL-DB_​and_​PDFs - Exercise

Session 4 - Introduction to Data Engineering

Exercise 01 Access Data from NoSQL Database and PDF Files

Learning objective: In this exercise you will practice the extraction of data from NoSQL database and unstructured data sources like PDF files. The extracted data will be used to update the database table


Workflow description: This workflow showcases how to access data from a NoSQL database and PDF files. The relevant fields are extracted from these files to transform the data in a tabular format, which is then used to update the database table. Find below the three major tasks performed in this workflow

  • The PDF files consisting of the renewal status of the business license are read from their respective locations. The textual data from these PDF files is extracted, then transformed to a standard table structure.

  • The validity of the renewed license is available in a NoSQL database - MongoDB. Connect to a MongoDB and read the semi-structured data from the MongoDB collection. We transform the extracted data to a standard table structure. The tables created from both data sources are joined to form one final table.

  • The "Inspection Overall" table in the database maintains the records for the stores and their license validity. This table is updated with the records from the final table created in the earlier step


You will find the instructions to the exercises in the yellow annotations.

Activity I. Extract Textual Data from PDF Files

  1. Parse the PDFs and read the textual data in it using the Tika Parser node.

    • To specify the directory, you need to use the KNIME Protocol (hint: try knime://knime.workflow/../../../data/Store_ID PDFs as the directory)

    • Select PDF and any other file formats of interest.

    • In the output table, the column Content contains the text from the PDF documents.

  2. Connect the first output port to the input of the metanode Extract License Status which cleans and transforms the relevant fields into table structure

Activity II. Extract Data from NoSQL Database

  1. Connect to a MongoDB database with the MongoDB Connector node. For your convenience, the node is already configured with the following settings:

    • Select the Connection Type as "SRV"

    • In the Instances, Hostname as "cluster0.p0ag5ht.mongodb.net" and leave the Port as blank

    • Enter the Authentication database name as "L2-DE_Session4"

    • For the Authentication, username and password are already provided


  2. Access the MongoDB collection using the MongoDB Reader node.

    • Connect the output of the MongoDB Connector node to the Input of the MongoDB Reader node.

    • In the configuration window, enter the following details

      Database : L2-DE_Session4
      Collection : License_Renewal

    • Execute the node and the output contains the data in JSON Format

  3. Convert the JSON format to the KNIME table format with the JSON to Table node

  4. Connect the output of the JSON to Table node to the Extract Validity metanode

Activity III. Update a Database Table

  1. Connect to a SQLite database with the SQLite Connector node

    • In the Connection Settings, select the Driver Name as "SQLite:[ID: SQLite]"

    • In the Location, select "Path" and Browse to the "my_central_database.sqlite" in the data folder*


  2. Update the Renewal Status and License Validity of the stores in the "Inspection_Overall" table in the SQLite database with the DB Update node.

    • Connect the Output of the String to Date&Time node to the first input of the DB Update node

    • Connect the Output from the SQLite Connector node to the second input of the DB Update node

    • In the Configuration dialog, select the following settings

      Table : Inspection_Overall
      Select Columns to Update: Renewal Status, License Validity
      Select Identification Column: Store_ID

    • Execute the node and the Inspection Overall table will be updated based on the data in the input of the DB Update node



* If you cannot locate the "my_central_database.sqlite" in your data folder, simply paste this path "knime://knime.workflow/../../../data/my_central_database.sqlite"



NoSQL Database
MongoDB Connector
Date Conversion
String to Date&Time
Extract License Status
Extract Validity
Joiner

Nodes

Extensions

Links