<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Khalif Cooper</title>
    <description>The latest articles on DEV Community by Khalif Cooper (@kooperkodes).</description>
    <link>https://dev.to/kooperkodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F255270%2F5e774066-7636-47e8-b142-fd3e76564734.jpg</url>
      <title>DEV Community: Khalif Cooper</title>
      <link>https://dev.to/kooperkodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kooperkodes"/>
    <language>en</language>
    <item>
      <title>Building ETL Pipelines in Python: Part 1</title>
      <dc:creator>Khalif Cooper</dc:creator>
      <pubDate>Sat, 21 Aug 2021 03:17:01 +0000</pubDate>
      <link>https://dev.to/kooperkodes/building-an-etl-pipeline-in-python-part-1-4a70</link>
      <guid>https://dev.to/kooperkodes/building-an-etl-pipeline-in-python-part-1-4a70</guid>
      <description>&lt;p&gt;Data engineering refers to the development of software that performs three tasks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extract raw data from various sources.&lt;/li&gt;
&lt;li&gt;Transform and clean up the data.&lt;/li&gt;
&lt;li&gt;Load the data into a data warehouse, i.e., a database management system like, Google BigQuery or Amazon Redshift.
Alternatively,load the data into MySQL, a relational database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The process is complex involving numerous software tools and advanced technical expertise. For one thing is can be challenging and overwhelming to identify the starting point and resources from which to acquire the basic knowledge. No wonder the demand for data engineers in the technology sector has risen by an order of magnitude in the past years. As the need for data generation grows, the thirst for data engineers will continue to intensify.&lt;/p&gt;

&lt;p&gt;This post, part 1 of a three-part tutorial shows you how to build a simple ETL[extract,transform,and load] pipeline with CSV files in Python, describes the extraction steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Software Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will need the following software:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;glob&lt;/code&gt;, a package that is preinstalled that searches for files in relative paths.&lt;br&gt;
For details, see this &lt;a href="https://docs.python.org/3/library/glob.html" rel="noopener noreferrer"&gt;section&lt;/a&gt; for documentation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;pandas&lt;/code&gt;, a package used for data manipulation. To install, type on the command line, &lt;code&gt;pip install pandas&lt;/code&gt;. &lt;br&gt;
For details, see the &lt;a href="https://pandas.pydata.org/" rel="noopener noreferrer"&gt;pandas&lt;/a&gt; site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;virtualenvwrapper&lt;/code&gt;, a package that sets up virtual environments for Python. For details, see the related &lt;a href="https://virtualenvwrapper.readthedocs.io/en/latest" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This &lt;a href="https://www.kaggle.com/antfarol/car-sale-advertisements" rel="noopener noreferrer"&gt;Kaggle dataset&lt;/a&gt; for the CSV data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an example of CSV data on car sales:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rxf6hzyk454gnr47hwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rxf6hzyk454gnr47hwr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Procedure:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a project called &lt;code&gt;etl_car_sales&lt;/code&gt; with PyCharm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a virtual environment with the command line &lt;code&gt;mkvirtualenv etl_car_sales&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;code&gt;pandas&lt;/code&gt; and &lt;code&gt;virtualenwrapper&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the zip file and move the CSV files for &lt;code&gt;car_sales&lt;/code&gt; to your &lt;code&gt;etl_car_sales&lt;/code&gt; directory, like this:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2s0uux2s9tqk710qp73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2s0uux2s9tqk710qp73.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;extract_from_csv&lt;/code&gt; function to read the CSV file
in your main directory and then return a Dataframe with the &lt;code&gt;pandas&lt;/code&gt; function &lt;code&gt;read_csv&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjavo6yl33v9tj7xrirz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjavo6yl33v9tj7xrirz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;extract&lt;/code&gt; function to read the data from the extracted csv file and append the data to the Dataframe that 
is being return the &lt;code&gt;extract_from_csv&lt;/code&gt; function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxyevo26ncf6ke0cchri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxyevo26ncf6ke0cchri.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: To rename the columns, do the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkyclgsqjdl9ybm6vkiwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkyclgsqjdl9ybm6vkiwk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Print out the &lt;code&gt;extracted_data&lt;/code&gt; variable and the result would read like this:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiszr5dgkb41e2fmsw4v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiszr5dgkb41e2fmsw4v2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part 2 will describe how to transform data in the ETL pipeline. Stay Tuned.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Classes and Objects in Dart: Part 1</title>
      <dc:creator>Khalif Cooper</dc:creator>
      <pubDate>Thu, 09 Apr 2020 15:49:19 +0000</pubDate>
      <link>https://dev.to/kooperkodes/classes-and-objects-in-dart-part-1-354p</link>
      <guid>https://dev.to/kooperkodes/classes-and-objects-in-dart-part-1-354p</guid>
      <description>&lt;p&gt;Do you ever have trouble with OOP? Object Oriented Programming. Do you know what it entails? Do you want to be able to not only understand the concepts but, be able to implement them as well? If you answered yes to any of the following questions, then today is your day.&lt;/p&gt;

&lt;p&gt;I will be creating a series of six parts going over objected oriented programming discussing classes, objects, constructors (abstraction, polymorphism, encapsulation and inheritance). Outside of classes, constructors, and objects; these four concepts make up what is called the four pillars or principles of object oriented programming.&lt;/p&gt;

&lt;p&gt;Other objected oriented languages that you might use everyday include Java, C#, C++, PHP, JavaScript, Smalltalk, Python, Dart, Swift, etc.&lt;/p&gt;

&lt;p&gt;Dart will be the language used in this series. If you want to follow along, you can use this awesome &lt;a href="https://dartpad.dev/"&gt;online dart editor&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; "class" is a keyword in dart and what follows after is the class name.&lt;/p&gt;

&lt;p&gt;Think of a class as an initial blueprint or template. Lets' imagine for a minute, a car with nothing on it, a bare bones car, with no wheels, no windows, no color, nothing. The car itself is a class. A class tells you "What" it is and a class can only be declared once. So, for example, a type of a car could be a Limo, Sedan, Truck, Van, and a Taxi; but at the end of the day, every type of car, is still a car itself. They are all made from the initial car. So lets' see what a car class looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;  &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now on to Objects! In the example above, we created an initial blueprint, "class" with the class name of "Car".&lt;/p&gt;

&lt;p&gt;An object is also the name of a class, which is "Car" in our case. And if we wanted to create one copy of the "Car" class; it will create an object that will be an instance of a class. So, to put it all together, every time a copy of the initial class is created, an instance of an object and class will be created as well.&lt;/p&gt;

&lt;p&gt;How? Lets' go back to our imagination again. You are at the dealership and you are not able to make up your mind what type of car you want. So you buy a Limo, Sedan, Truck, Van, and a Taxi. Every car that is made will use this original "Car" model class to create another one. All of those types of cars, will be considered objects that are "instances" or copies derived from the original "Car" class we made above. So in code that would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

   &lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;limo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;sedan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;van&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;taxi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

     &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//instance of 'Car'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Dart, we use the "void" keyword, which is used when you create a method or function that doesn't return a value. The main method is required in dart to run any code. And In the main method we use the "new" keyword to create those instances. When we print out the limo instance, it tells us, we created an instance of the car class.&lt;/p&gt;

&lt;p&gt;Now that is cleared up, lets' go back to our "Car" class. Inside of our "Car" class, we need to include some information or details as well as functionality about our car. For example, color, wheels, windows, make, how fast it goes, what sound does the car make etc..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;wheels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;windows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;mph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"up to &lt;/span&gt;&lt;span class="si"&gt;$speed&lt;/span&gt;&lt;span class="s"&gt; mph"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;carEngineStart&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
       &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"zzzrrrroooommmm"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;


   &lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;limo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;sedan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;van&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;taxi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

     &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wheels&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 4&lt;/span&gt;
     &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;windows&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 4&lt;/span&gt;
     &lt;span class="n"&gt;limo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;carEngineStart&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="c1"&gt;// zzzrrrroooommmm&lt;/span&gt;
     &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;mph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;65&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;span class="c1"&gt;// up to 65 mph&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example, we created a void method that takes an integer and prints out the speed and string method that prints out car sound. Then in the main method, we called those methods on the instances.&lt;/p&gt;

&lt;p&gt;Hope you learned about what OOP is in this article. And learned in summary, that when a class is first created, it creates a blueprint of an object. Also inside of a class, you can create methods and properties that can be initialize when you create multiple copies or instances of the original class. And when you will create instances of the class. You also create instances of the object as well.&lt;/p&gt;

</description>
      <category>dart</category>
      <category>oop</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
