<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hassaan Yousaf on Medium]]></title>
        <description><![CDATA[Stories by Hassaan Yousaf on Medium]]></description>
        <link>https://medium.com/@hassaan.yousaf1025?source=rss-eecffbd0fdc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*k1o2vkD9PV9TQooLnlAWnQ.jpeg</url>
            <title>Stories by Hassaan Yousaf on Medium</title>
            <link>https://medium.com/@hassaan.yousaf1025?source=rss-eecffbd0fdc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:54:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hassaan.yousaf1025/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Engineering Project: A Deep Dive into AWS, Snowflake, SSMS, and Talend Integration]]></title>
            <link>https://medium.com/@hassaan.yousaf1025/data-engineering-project-a-deep-dive-into-aws-snowflake-ssms-and-talend-integration-f550eef62bf0?source=rss-eecffbd0fdc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f550eef62bf0</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[talend]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hassaan Yousaf]]></dc:creator>
            <pubDate>Fri, 20 Sep 2024 13:38:29 GMT</pubDate>
            <atom:updated>2024-12-22T10:07:38.671Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceodaEck2h_z0ZHgjWcztw.png" /></figure><p>In today’s rapidly evolving data landscape, businesses face an unprecedented influx of data from diverse sources. The need for efficient, scalable, and secure data management solutions has never been more critical. Modern enterprises rely on cloud platforms like <strong>Amazon Web Services (AWS)</strong> for scalable storage, powerful data warehousing solutions like <strong>Snowflake</strong> for real-time analytics, <strong>SQL Server Management Studio (SSMS)</strong> for managing traditional relational databases, and comprehensive <strong>ETL tools like Talend</strong> for seamless data integration and transformation across platforms.</p><p>Seamless integration of these powerful technologies can significantly enhance data workflows by providing a unified system for <strong>data extraction, transformation, and loading (ETL)</strong>, while also ensuring strong <strong>security protocols</strong>, <strong>role-based access control</strong>, and optimized data management practices. From ensuring the secure transfer of data between cloud and on-premise systems to automating data ingestion and storage, each tool plays a crucial role in the broader data ecosystem.</p><p>This technical guide delves into the intricacies of integrating AWS, Snowflake, SSMS, and Talend, offering step-by-step processes for building a robust, secure, and scalable data pipeline. Whether it’s setting up <strong>AWS Identity and Access Management (IAM)</strong> for secure access control, leveraging <strong>Snowflake’s external stages</strong> for efficient data flow, or using <strong>Talend</strong> to streamline ETL operations, this guide provides detailed insights into best practices and advanced configurations for seamless data movement.</p><p>By the end of this guide, you’ll have a comprehensive understanding of how these tools interact and how to harness their capabilities to optimize your data architecture, automate processes, and future-proof your data management systems.</p><h4>Setting Up AWS for Robust Access Control</h4><p>The foundation of a secure cloud-based system starts with meticulous role setup and permission management in AWS Identity and Access Management (IAM).</p><ul><li><strong>Creating IAM Roles</strong>: Begin by crafting an IAM role specifically for Snowflake, enabling it to interact with AWS S3. This role is pivotal for delineating what actions Snowflake can perform on the S3 buckets.</li><li>Create Role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcFP0CCXEi9WSYcOnBpFHw.png" /></figure><ul><li>S3 Access to the role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7Lm7IJshp5AbvRlD_LaSA.png" /></figure><ul><li>Give role a name and description:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8o_3Y4pGakGgp3Hf8N91nA.png" /></figure><ul><li>Click on the IAM Role and Copy ARN:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4ydSCtCYBDKaEbGFRcCcA.png" /></figure><ul><li>Create an S3 Bucket:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*rCWtzThXPh3cqrbrc4ynRQ.png" /></figure><p>This complete process involves defining the role details and attaching policies directly related to S3 access, ensuring a tight security posture.</p><h4>Configuring Snowflake Storage Integration with AWS</h4><p>Snowflake integration with AWS S3 involves setting up storage integrations that allow Snowflake to securely access S3 buckets.</p><ul><li><strong>External Stages and File Formats</strong>: Define external stages in Snowflake that map to S3 buckets, specifying file formats to handle the data appropriately.</li><li>Code to run on Snowflake:</li></ul><pre>CREATE OR REPLACE storage integration st_intg<br>    TYPE = EXTERNAL_STAGE<br>    STORAGE_PROVIDER = S3<br>    ENABLED = TRUE<br>    STORAGE_AWS_ROLE_ARN = &#39;arn:aws:iam::158478452053:role/HY-snowrole-2&#39;<br>    STORAGE_ALLOWED_lOCATIONS = (&#39;s3://hy-snowbucket/&#39;)</pre><ul><li>Create the storage integration and view the details using</li></ul><pre>DESC STORAGE INTEGRATION st_intg;</pre><ul><li>This line of code will give you the following information:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFKxTUb0dl1XS7L6QVqkwA.png" /></figure><blockquote>Important to Note:<br>Copy the value of <strong>STORAGE_AWS_IAM_USER_ARN</strong> which will be used in entrusted relationships in IAM role</blockquote><h4>Empowering SSMS with User and Role Configurations</h4><p>Microsoft SQL Server Management Studio (SSMS) provides local database management. Proper configuration of users and roles ensures security and operational efficiency.</p><ul><li><strong>User Creation and Role Assignment</strong>: Step-by-step guide on setting up user logins and roles within SSMS to ensure that users have the appropriate permissions to execute operations.</li><li>Go to the server and you&#39;ll find security tab in there. Under the secrutiy tab, go for logins and create a user:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*j9UZP0cukg_E-zRGVxB1mQ.png" /></figure><ul><li>You would need to assign the following roles to your user:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*hKmWAR-8Xj4IN1CAF3CQ8w.png" /></figure><p>Next step is to map this user to your database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*-9KnvzNwk6mdlmfO3_EWdA.png" /></figure><blockquote>Important to Note:</blockquote><blockquote>It is necessary to give db_owner privileges to this user. Do not focus on the database name as it can be anything for you.</blockquote><p>To verify either the user has been configured to the DB or not, go to your database and under security tab you will find this user mapped to it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*OexoAgx86URKFu18f0bcLw.png" /></figure><h4>Bridging Gaps with Talend</h4><p>Talend acts as the orchestrator in our data flow, facilitating efficient ETL processes between SSMS and Snowflake.</p><ul><li><strong>SSMS Integration in Talend</strong>: Establish connections to both SSMS and Snowflake. This includes entering credentials, specifying server details, and testing the connection to ensure seamless communication.</li><li><strong>Screenshot</strong>: Detailed connection settings in Talend show how to configure the database connection, emphasizing the importance of correct settings for reliable data transfers.</li><li>Go to DB Connections:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*4lrx02G-kUV52G15sRIocQ.png" /></figure><ul><li>Insert the following information:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*CvoSA7FUHvSMcQ4XW9360w.png" /></figure><ul><li>Once the connection is developed, select your table:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*O2iB0ScC_NUfw8eSZYqmvw.png" /></figure><p>This will setup your Talend connection with your SQL database on SSMS.</p><ul><li><strong>Snowflake Integration in Talend</strong>: Manage the connection to your snowflake account to make Talend access your table that needs to be inserted with the data.</li></ul><blockquote>Important to note: This table has to be created first in your snowflake</blockquote><pre>Use SNOW_DB<br><br>CREATE or REPLACE TABLE Data_engineer<br>(<br>    JobTitle        TEXT,<br>    SalaryEstimate  TEXT,<br>    Rating          TEXT,<br>    Company         TEXT,<br>    Location        TEXT,<br>    HQ              TEXT,<br>    Size            TEXT,<br>    Founded         TEXT,<br>    TypeOfOwnership TEXT,<br>    Industry        TEXT,<br>    Sector          TEXT,<br>    Revenue         TEXT,<br>    Competitors     TEXT,<br>    EasyApply       TEXT<br>);s</pre><ul><li>Now build connection with Snowflake from Talend.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*d9oGkDKrsgaXm87ReD-zUw.png" /></figure><p>Your job at Talend is complete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Q5fxw_uQalkIznksROWiw.png" /></figure><h4>Automating Data Flow with Snowpipe</h4><p><strong>Snowpipe</strong> is a Snowflake service that continuously ingests data from AWS S3. The following commands demonstrate how to automate data transfer from Snowflake to S3:</p><p>This specifies the structure of files to be exported:</p><pre>CREATE OR REPLACE FILE FORMAT hy_csv1<br>  TYPE = &#39;CSV&#39;<br>  FIELD_DELIMITER = &#39;,&#39;<br>  FIELD_OPTIONALLY_ENCLOSED_BY = &#39;&quot;&#39;<br>  NULL_IF = (&#39;NULL&#39;, &#39;&#39;)<br>  SKIP_HEADER = 1<br>  COMPRESSION = NONE;</pre><p>This will create a file format in which the file has to be shared in S3. It can vary depending on the use case as all kind of structured file formats can be exported.</p><pre>create or replace stage Snow_stage<br>url = &#39;s3://hy-snowbucket/&#39;<br>credentials = (aws_key_id = &#39;AKIASJZQNIVK5UHLSADL&#39; aws_secret_key = &#39;7/7GlbywFYokYBhOQQ7905hBmUIEHp6cSK6q7OBy&#39;)<br>file_format = hy_csv1</pre><p>A data stage is to be created where your data is to be dumped.</p><pre>create or replace pipe snowpipe auto_ingest = true as<br>COPY INTO @Snow_stage/data_engineer_export.csv<br>  FROM (SELECT * FROM DataEngineer)<br>  FILE_FORMAT = (FORMAT_NAME = &#39;hy_csv1&#39;)<br>  HEADER = TRUE<br>  SINGLE = TRUE  -- To create a single CSV file instead of multiple partitions<br>  OVERWRITE = TRUE;</pre><p>This will Automate data export by defining a <strong>Snowpipe</strong>, which continuously moves data from Snowflake to your S3 bucket.</p><p>For monitoring and managing the snowpipe, there are additional commands that need to be studied and implemetned as well.</p><pre>Alter pipe snowpipe refresh</pre><p>In our case, where Snowpipe <strong>exports</strong> data from Snowflake to S3, the <strong>refresh</strong> functionality or manual intervention isn’t relevant the same way. Instead:</p><ul><li><strong>ALTER PIPE snowpipe REFRESH</strong>: <strong>This command is typically not used in your scenario</strong> because you are pushing data from Snowflake to S3, not ingesting it from S3. There is no need to manually &quot;refresh&quot; or re-check the S3 stage, as there are no files being ingested from S3 into Snowflake.</li><li>The REFRESH command is usually useful when Snowpipe is used for <strong>continuous file ingestion from S3</strong> into Snowflake, where you might need to tell Snowpipe to recheck or reload missed files. In your case, this is irrelevant because the Snowpipe is exporting, not importing.</li></ul><pre>select system$pipe_status(&#39;SNOW_DB.public.snowpipe&#39;)</pre><p>This command queries the system function system$pipe_status to check the status of the specified Snowpipe. It gives information about whether the pipe is currently active, paused, or encountering errors.</p><ul><li><strong>SNOW_DB.public.snowpipe</strong>: This is the fully qualified name of the Snowpipe (including the database and schema).</li><li><strong>Return values</strong>: The result might include details like the number of files processed, any errors encountered, or whether the pipe is currently paused or running.</li></ul><pre>select * from table(validate_pipe_load(<br>    pipe_name =&gt; &#39;SNOW_DB.public.snowpipe&#39;,<br>    start_time =&gt; dateadd(hour, -1, current_timestamp())<br>))</pre><p>This command checks the data loading status of a Snowpipe by using the validate_pipe_load table function. It helps you analyze if there were any issues with loading data, such as rows being rejected or errors occurring during the data load.</p><ul><li><strong>pipe_name =&gt; &#39;SNOW_DB.public.snowpipe&#39;</strong>: Specifies the Snowpipe that is being validated for data load status.</li><li><strong>start_time =&gt; dateadd(hour, -1, current_timestamp())</strong>: Specifies the start time for the validation, looking back one hour from the current timestamp. This helps you focus the validation on recent loads.</li></ul><p>The output will show whether there were any issues (e.g., file load errors) during the period you specified.</p><pre>alter pipe snow_db.public.snowpipe set pipe_execution_paused = true</pre><p>This command pauses the execution of the specified Snowpipe. When a Snowpipe is paused, it will stop ingesting new files from the external stage (like S3) until it is resumed.</p><ul><li><strong>snow_db.public.snowpipe</strong>: This is the fully qualified name of the Snowpipe, including its database and schema.</li><li><strong>pipe_execution_paused = TRUE</strong>: Sets the pipe to a paused state. When paused, Snowpipe does not auto-ingest new files, but the pipe remains available for other actions like querying its status.</li></ul><p><strong>Conclusion</strong><br>Integrating AWS, Snowflake, SSMS, and Talend into your data pipeline ensures a robust and efficient system capable of handling modern data challenges. From secure storage in AWS S3 to seamless data transfers with Talend and automated Snowpipe processes, this comprehensive guide empowers data engineers to enhance operational efficiency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f550eef62bf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ford Vs Tesla: End-to-End Project of Stocks Data Analysis and Visualization with R]]></title>
            <link>https://medium.com/@hassaan.yousaf1025/ford-vs-tesla-a-journey-into-stocks-data-analysis-and-visualization-with-r-40ee178de892?source=rss-eecffbd0fdc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/40ee178de892</guid>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[ford]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[tesla]]></category>
            <dc:creator><![CDATA[Hassaan Yousaf]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 11:43:31 GMT</pubDate>
            <atom:updated>2023-12-26T14:17:38.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJ85Xim34Cg7A-2UkKY9kQ.png" /></figure><p>Data analytics is revolutionizing industries, and the automobile sector is no exception. Two giants, Ford and Tesla, have trajectories that offer a goldmine of data for analysis. If you’re venturing into R and data analysis, this guide offers a hands-on blend of R code and its resulting visual insights, comparing these automobile titans. Let’s kick things into gear!</p><h3>Setting the Stage: Data Preparation</h3><p>Our analysis begins with a few foundational steps:</p><ul><li><strong>Loading Libraries:</strong> Essential R packages tidyverse, ggplot2, and dplyr are ushered in, facilitating data manipulation and visualization.</li><li><strong>Data Ingestion:</strong> read.csv is our gateway to bring in our datasets, creating the data frames Ford and Tesla.</li><li><strong>Cleaning:</strong> We ensure our data is pristine and missing-value-free with is.na and complete.cases.</li></ul><pre># Load the libraries<br>library(tidyverse)<br>library(ggplot2)<br>library(dplyr)<br>library(scales)<br>library(hrbrthemes)<br><br># Read csv file <br>Ford &lt;- read.csv(&quot;D:/Data_Analytics/F.csv&quot;) #Ford<br>head(Ford)<br>      Date     Open     High      Low    Close Adj.Close  Volume<br>1 6/1/1972 0.000000       NA 2.149165 2.153220  0.277406 1091238<br>2 6/2/1972 2.153220 2.173495 2.141055 2.149165  0.276884 1174468<br>3 6/5/1972 2.149165 2.169440 2.141055 2.149165  0.276884 5209582<br>4 6/6/1972 2.149165 2.157275 2.116725 2.124835  0.273750 1424158<br>5 6/7/1972 2.124835 2.137000 2.112670 2.112670  0.272182  675088<br>6 6/8/1972 2.112670 2.128890 2.096449 2.096449  0.270093 1038834<br><br>Tesla &lt;- read.csv(&quot;D:/Data_Analytics/Tesla.csv&quot;) #Tesla<br>head(Tesla)<br>       Date  Open  High   Low Close Adj.Close   Volume<br>1 6/29/2010 3.800 5.000 3.508 4.778     4.778 93831500<br>2 6/30/2010 5.158 6.084 4.660 4.766     4.766 85935500<br>3  7/1/2010 5.000 5.184 4.054 4.392     4.392 41094000<br>4  7/2/2010 4.600 4.620 3.742 3.840     3.840 25699000<br>5  7/6/2010 4.000 4.000 3.166 3.222     3.222 34334500<br>6  7/7/2010 3.280 3.326 2.996 3.160     3.160 34608500<br><br># Check empty column <br>colSums(is.na(Ford) | Ford == &quot;&quot;)<br>colSums(is.na(Tesla) | Tesla == &quot;&quot;)<br><br>&gt; colSums(is.na(Ford) | Ford == &quot;&quot;)<br>     Date      Open      High       Low     Close Adj.Close    Volume <br>        0         0         1         0         0         0         0 <br>&gt; colSums(is.na(Tesla) | Tesla == &quot;&quot;)<br>     Date      Open      High       Low     Close Adj.Close    Volume <br>        0         0         0         0         0         0         0 <br><br># Clean data<br>Ford[Ford==0] &lt;- NA #Set zero to NA<br>Ford&lt;-Ford[complete.cases(Ford),] # Delete rows associated with NA<br>head(Ford)<br><br>Tesla[Tesla==0] &lt;- NA #Set zero to NA<br>Tesla&lt;-Tesla[complete.cases(Tesla),] # Delete rows associated with NA<br>head(Tesla)<br><br># Round the numeric column <br>Ford &lt;- Ford %&gt;% mutate_if(is.numeric, round, digits=2)<br>head(Ford)<br><br>Tesla &lt;- Tesla %&gt;% mutate_if(is.numeric, round, digits=2)<br>head(Tesla)<br><br># Create a new columns Year and Name<br><br>Ford$Date &lt;- as.Date(Ford$Date , &quot;%m/%d/%Y&quot;) # Convert date variable into date format<br>Ford$Date &lt;- as.Date(Ford$Date) # make sure the date is indeed a date<br>Ford$year &lt;- as.numeric(format(Ford$Date, &quot;%Y&quot;)) # extract the year and convert to numeric format<br>Ford$Name &lt;-  &quot;Ford&quot; # Create a new column<br>head(Ford)<br><br>Tesla$Date &lt;- as.Date(Tesla$Date , &quot;%m/%d/%Y&quot;)<br>Tesla$Date &lt;- as.Date(Tesla$Date) # make sure the date is indeed a date<br>Tesla$year &lt;- as.numeric(format(Tesla$Date, &quot;%Y&quot;)) # extract the year and convert to numeric format<br>Tesla$Name &lt;-  &quot;Tesla&quot;  # Create a new column<br>head(Tesla)<br><br># Combine two data frames vertically<br>Automobiles &lt;- rbind(Ford, Tesla) <br>head(Automobiles)</pre><h3>1. Distribution Of Automobiles:</h3><p><strong>Code Breakdown:</strong> A bar graph using ggplot visualizes the count of data points for Ford and Tesla.</p><pre># Plot the distribution of Automobiles<br>ggplot(Automobiles, aes(x = Name)) + <br>  geom_bar(fill = &quot;#DD8888&quot;, color=&quot;black&quot;) +<br>  labs(x = &quot;Autombiles&quot;,  y = &quot;Frequency&quot;, title = &quot;Distribution Of Automobiles&quot;) +<br>  theme(plot.title = element_text(hjust = 0.5))</pre><p><strong>Trends &amp; Insights:</strong> The graph paints a clear picture: Ford has a substantially higher data count than Tesla, suggesting a longer data history for Ford. For novice analysts, gauging the volume of your dataset is pivotal as it can shape your subsequent insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*RBm-v-t1dlvqTpdCgBJVnA.png" /></figure><h3>2. Volume of Each Car Type by Year:</h3><p><strong>Code Breakdown: </strong>A bar graph visualizes the yearly sales volume of both brands, grouped annually.</p><pre># Plot the No. of units sold of each car type by year<br>ggplot(Automobiles, aes(fill=Name, y=Volume, x=year)) + <br>  geom_bar(position=&quot;dodge&quot;, stat=&quot;identity&quot;)+<br>  labs(title=&quot;Volume of each Car type by year&quot;, subtitle = &quot;Number of units Sold&quot;, x=&quot;Year&quot;, y=&quot;Volume&quot;)</pre><p><strong>Trends &amp; Insights:</strong> Historically, Ford’s sales towered over Tesla’s. However, a noticeable upward trend for Tesla post-2010 signals its rising market presence and the global tilt towards electric vehicles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*1vFACAJ6xeLfSpFixzPRtw.png" /></figure><h3>3. Comparing Mean Price from the First Transaction:</h3><p><strong>Code Breakdown:</strong> A line graph delineates the average opening stock prices over the years.</p><pre># Summarize for Open(Price from the first transaction of a trading day) for automobiles each year<br>OpenPrice &lt;- Automobiles_ %&gt;%<br>  group_by(year,Name) %&gt;%<br>  summarize(<br>    n=n(),<br>    maxOpen = max(Open),<br>    minOpen = min(Open),<br>    meanOpen= mean(Open),<br>    sdOpen = sd(Open),<br>    seOpen = sdOpen / sqrt(n)<br>  )<br>OpenPrice_df  &lt;- as.data.frame(OpenPrice) # Change into Data Frame<br>head(OpenPrice_df)<br>year  Name   n maxOpen minOpen  meanOpen    sdOpen     seOpen<br>1 2010  Ford 252   17.19   10.10 12.938373 1.8423359 0.11605626<br>2 2010 Tesla 130    7.17    3.23  4.681615 1.0145093 0.08897835<br>3 2011  Ford 252   18.81    9.22 13.233175 2.4406657 0.15374748<br>4 2011 Tesla 252    6.93    4.36  5.364683 0.5562949 0.03504329<br>5 2012  Ford 250   13.03    8.99 10.954240 1.1692044 0.07394698<br>6 2012 Tesla 250    7.64    5.32  6.240360 0.5233943 0.03310236<br><br># Plot the Mean of Open by name and year<br>ggplot(OpenPrice_df, aes(x= factor(year, <br>        labels = c(&quot;2010&quot;,&quot;2011&quot;,&quot;2012&quot;,&quot;2013&quot;,&quot;2014&quot;,&quot;2015&quot;,&quot;2016&quot;,&quot;2017&quot;,&quot;2018&quot;,&quot;2019&quot;,&quot;2020&quot;,&quot;2021&quot;)),<br>                   y = meanOpen, group=Name, color=Name)) +<br>        geom_point(size = 3) +  geom_line(size = 1) + scale_y_continuous(label = dollar) +<br>        labs(title=&quot; Comparing Mean Price from the first transaction &quot; , x=&quot;Year&quot;, y=&quot;Mean Price &quot;) +<br>        theme(plot.title = element_text(hjust = 0.5))</pre><p><strong>Trends &amp; Insights:</strong> Ford’s trajectory has been stable, but Tesla’s mean price skyrockets after 2020, indicating potential market shifts or significant events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*fDzG6C66tOgtKHNxuOOiFA.png" /></figure><h3>4. Prices for Ford and Prices for Tesla:</h3><p><strong>Code Breakdown:</strong> Line graphs capture stock price variations (Open, High, Low, Close) across years.</p><pre>#Plotting after the rapid increase for Tesla<br>par(mfrow=c(2,1))<br>Ford %&gt;% <br>  ggplot()+<br>  geom_line(aes(x = Date, y = Open))+<br>  geom_line(aes(x = Date, y = High), color=&quot;yellow&quot;)+<br>  geom_line(aes(x = Date, y = Low), color=&quot;red&quot;)+<br>  geom_line(aes(x = Date, y = Close), color=&quot;blue&quot;)+ scale_y_continuous(label = dollar) +<br>  labs(title=&quot; Prices for Ford &quot; , x=&quot;Year&quot;, y=&quot;Price&quot;) +<br>  theme(plot.title = element_text(hjust = 0.5))<br>Tesla %&gt;% <br>  ggplot()+<br>  geom_line(aes(x = Date, y = Open))+<br>  geom_line(aes(x = Date, y = High), color=&quot;yellow&quot;)+<br>  geom_line(aes(x = Date, y = Low), color=&quot;red&quot;)+<br>  geom_line(aes(x = Date, y = Close), color=&quot;blue&quot;)+ scale_y_continuous(label = dollar) +<br>  labs(title=&quot; Prices for Tesla &quot; , x=&quot;Year&quot;, y=&quot;Price&quot;) +<br>  theme(plot.title = element_text(hjust = 0.5))</pre><p><strong>Trends &amp; Insights:</strong> Ford’s journey sees peaks and troughs, while Tesla’s ascent post-2015 is unmissable, underscoring its bullish stock market stance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*YtuXN1usqO8oXGZIzn3BLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*00Gz_zUaLvqBHNCftio1rg.png" /></figure><h3>5. Comparative Analysis of Maximum and Minimum Prices:</h3><p><strong>Code Breakdown:</strong> Bar graphs contrast the yearly maximum and minimum stock prices.</p><pre># Filter the data between  year 2010 and 2020<br>Automobiles_ &lt;- Automobiles %&gt;% <br>  filter(&quot;2009&quot;&lt;year,year&lt;&quot;2020&quot;)<br>Automobiles_<br><br># Filter the data<br>OpenPrice_ &lt;- OpenPrice_df %&gt;%<br>  filter(&quot;2009&quot;&lt;year,year&lt;&quot;2020&quot;)<br>head(OpenPrice_)<br><br># Plot again After Filtering<br>par(mfrow=c(3,1))<br>ggplot(OpenPrice_, aes(x = year, y = meanOpen, group=Name, color=Name)) +<br>  geom_point(size = 3) + geom_line(size = 1) +   scale_y_continuous(label = dollar) +<br>  labs(title=&quot; Comparing Mean Price from the first transaction &quot;,<br>       x=&quot;Year&quot;, y=&quot;Mean Price&quot;) +  theme(plot.title = element_text(hjust = 0.5))<br><br>ggplot(OpenPrice_, aes(fill=Name, y=maxOpen,x= factor(year, <br>               labels = c(&quot;2010&quot;,&quot;2011&quot;,&quot;2012&quot;,&quot;2013&quot;,&quot;2014&quot;,&quot;2015&quot;,&quot;2016&quot;,&quot;2017&quot;,&quot;2018&quot;,&quot;2019&quot;)))) + <br>  geom_bar(position=&quot;dodge&quot;, stat=&quot;identity&quot;)+ scale_y_continuous(label = dollar) +<br>  labs(title=&quot; Comparing Maximum Price from the first transaction for Tesla and Ford each year&quot;,<br>       x=&quot;Year&quot;, y=&quot;Maximum Price &quot;) +  theme(plot.title = element_text(hjust = 0.5))<br><br>ggplot(OpenPrice_, aes(fill=Name, y=minOpen,x= factor(year, <br>                      labels = c(&quot;2010&quot;,&quot;2011&quot;,&quot;2012&quot;,&quot;2013&quot;,&quot;2014&quot;,&quot;2015&quot;,&quot;2016&quot;,&quot;2017&quot;,&quot;2018&quot;,&quot;2019&quot;)))) + <br>  geom_bar(position=&quot;dodge&quot;, stat=&quot;identity&quot;)+  scale_y_continuous(label = dollar) +<br>  labs(title=&quot; Comparing Minimum Price from the first transaction for Tesla and Ford&quot;,<br>       x=&quot;Year&quot;, y=&quot;Minimum Price &quot;) +  theme(plot.title = element_text(hjust = 0.5))</pre><p><strong>Trends &amp; Insights:</strong> Both brands ride the roller-coaster of stock price fluctuations. Yet, Tesla’s recent years stand out, showcasing a bullish market sentiment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*oD2NhATRMez30hJz0kQOUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*TUZsCEN31qtMJ2c_51IIMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*P1o6gNXSs36cJDC_BOzzUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*OnNrmeW3EZdtgdL5ZoP6_A.png" /></figure><h3>6. Yearly Price Fluctuations:</h3><p><strong>Code Breakdown:</strong> We calculate the yearly price shifts and visualize them using column graphs.</p><pre># Summary for Yearly Change<br>Yearly &lt;- Automobiles_ %&gt;% <br>  group_by(year,Name) %&gt;% <br>  summarise(<br>    high = max(High),<br>    low = min(Low),<br>  )<br>Yearly<br><br>#Change in Highest price<br>Yearly$changeHigh = (Yearly$high - lag(Yearly$high))<br>Yearly<br>#Change in Lowest price<br>Yearly$changeLow = (Yearly$low - lag(Yearly$low))<br>Yearly<br><br># Plot the change<br>Yearly %&gt;% <br>  ggplot()+<br>  geom_col(aes(x= factor(year, <br>                         labels = c(&quot;2010&quot;,&quot;2011&quot;,&quot;2012&quot;,&quot;2013&quot;,&quot;2014&quot;,&quot;2015&quot;,&quot;2016&quot;,&quot;2017&quot;,&quot;2018&quot;,&quot;2019&quot;)), <br>               y = changeHigh, fill = changeHigh))+<br>  scale_fill_gradient2(low =&quot;red&quot;,<br>                       mid = &quot;white&quot;,<br>                       high = &quot;green&quot;,<br>                       midpoint = 0)+ <br>  labs(title = &quot;Yearly change in Highest Prices&quot;, x = &quot;Year&quot;,   y = &quot;Change&quot;)<br><br>Yearly %&gt;% <br>  ggplot()+<br>  geom_col(aes(x= factor(year, <br>                         labels = c(&quot;2010&quot;,&quot;2011&quot;,&quot;2012&quot;,&quot;2013&quot;,&quot;2014&quot;,&quot;2015&quot;,&quot;2016&quot;,&quot;2017&quot;,&quot;2018&quot;,&quot;2019&quot;)),<br>               y = changeLow, fill = changeLow))+<br>  scale_fill_gradient2(low =&quot;red&quot;,<br>                       mid = &quot;white&quot;,<br>                       high = &quot;blue&quot;,<br>                       midpoint = 0)+<br>  labs(title = &quot;Yearly change in Lowest Prices&quot;, x = &quot;year&quot;,   y = &quot;Change&quot;,color = &quot;Name&quot;)</pre><p><strong>Trends &amp; Insights:</strong> The dance of green, blue, and red columns reveals years of growth and decline for both brands. Such patterns are pivotal for investors, providing insights into market volatility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*l_BwX_nKCQ7fHSGj4Nxhmw.png" /><figcaption>s</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*62sHIIHH1VnNpSsZDhTy5Q.png" /></figure><h3>Conclusion:</h3><p>Marrying R code with visual insights, we’ve embarked on a journey, unraveling the tales of Ford and Tesla. This hands-on narrative not only demystifies R’s intricacies but underscores the prowess of data analytics. If you’re setting sail in the R world, let this be your compass, guiding you through the vast seas of data analysis. Keep charting, coding, and let the stories in data come alive!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40ee178de892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Engineering ETL: Automating CSV Imports to Data Lake in SSMS — A Hands-On Guide]]></title>
            <link>https://medium.com/@hassaan.yousaf1025/data-engineering-etl-automating-csv-imports-to-data-lake-in-ssms-a-hands-on-guide-68e014d9eea9?source=rss-eecffbd0fdc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/68e014d9eea9</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Hassaan Yousaf]]></dc:creator>
            <pubDate>Thu, 30 Nov 2023 19:33:16 GMT</pubDate>
            <atom:updated>2023-11-30T19:33:16.155Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Engineering ETL: Automating CSV Imports to Data Lake in SSMS — A Hands-On Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0yr3lLLT26k1Lff-dykzA.jpeg" /></figure><p>In the dynamic field of technology, data engineering jobs, doubling annually, are a burgeoning force, particularly in the United States with an average salary of $116k. This industry not only craves financial appeal but seeks fresh talents adept at crafting and sustaining data products within complex systems. Over two years, data creation skyrockets at 7MB per second per person, highlighting the pressing need for skilled data engineers. Beyond statistics, these roles symbolize a fusion of creativity and technical prowess in navigating evolving data infrastructures. This essay delves into the exponential growth and lucrative opportunities, positioning data engineers as architects shaping the future of industries.</p><p>Achieving breakthroughs in this field is recognized as challenging due to the depth of expertise and skills demanded. This underscores the necessity for self-directed learning, motivating the initiation of data engineering projects. Many online platforms typically incur costs, serving as significant barriers to project completion. This project, however, capitalizes on your local environment, utilizing technologies that are entirely free of any associated costs.</p><p>In this project, you will roam around the following data engineering concepts that you can use this project as an example to relate with:</p><ul><li>Real-time ingestion</li><li>Batch ingestion</li><li>Relational databases</li><li>Data warehouses</li><li>Data lakes</li><li>Data Modeling</li><li>Entity-relationship modeling</li><li>Dimensional modeling</li><li>Schema design</li><li>ETL (Extract, Transform, Load)</li><li>Reverse ETL</li><li>ELT (Extract, Load, Transform)</li><li>Data wrangling</li><li>Data profiling</li><li>Data cleansing</li><li>Data validation</li><li>Metadata Management</li><li>Metadata repositories</li><li>Data Governance</li><li>Data Pipelines</li><li>Orchestration</li><li>Workflow management</li><li>Data Security</li><li>Data Warehousing</li><li>Snowflake schema</li><li>Star schema</li><li>Data Ethics</li><li>Privacy</li><li>Bias in data</li><li>Database Indexing.</li><li>Types of indexes</li><li>Index optimization</li><li>Data Migration</li><li>Data Collaboration</li></ul><p>We will delve into some of these concepts using our project as an example. Please look out for ‘psst’ followed by a tidbit about these concepts.</p><h3>Data Extraction:</h3><p>The journey begins with the creation of a Data Landing Zone.</p><p><strong><em>Psst:</em></strong> In broader terms, this represents your ‘<strong>Data Lake</strong>’ serving as the repository for all raw data. It serves as the initial stage in your ‘<strong>ETL</strong>’ process. The forthcoming database we are constructing is a ‘<strong>Relational Database</strong>’ comprising tables and rows specifically designed for sales data.</p><p>Establish a connection with your SQL server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*gsBM0QbIA_DzG_6Q1oWDrA.png" /></figure><p>Develop a database to function as the landing zone for incoming data in CSV formats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z5eE-W3HkseuBihV4UeI5A.png" /></figure><p>You need to have Visual Studio Code installed on your server along with Python to write an extraction code for CSV data extraction and Loading into your ‘Test’ database. The following code will extract the data from all CSV files in the folder and store it in the ‘Test’ database with table names the same as the file name.</p><p><strong><em>Psst: </em></strong>With additional refinement, this system can seamlessly transition into both ‘<strong>Real-Time Data Ingestion</strong>’ and ‘<strong>Batch Ingestion</strong>.’ At this phase, integrate ‘<strong>Metadata Management’ </strong>concepts by meticulously tracking ‘<strong>Metadata Repositories’ </strong>and embedding them into an additional column alongside the extracted data.</p><pre>import pandas as pd<br>import pyodbc<br>import os<br><br>server = &#39;HASSAAN&#39;<br>database = &#39;Test&#39;<br>driver = &#39;{SQL Server}&#39;<br><br>conn = pyodbc.connect(f&#39;DRIVER={driver};SERVER={server};DATABASE={database};&#39;)<br><br>folder_path = r&#39;D:\Interviews\Data&#39;<br><br>csv_files = [f for f in os.listdir(folder_path) if f.endswith(&#39;.csv&#39;)]<br><br>for csv_file in csv_files:<br>    df = pd.read_csv(os.path.join(folder_path, csv_file))<br>    columns = list(df.columns)<br>    <br>    table_name = os.path.splitext(csv_file)[0]<br><br>    # Remove any invalid characters from the table name<br>    table_name = &#39;&#39;.join(c if c.isalnum() or c in [&#39;_&#39;, &#39;-&#39;] else &#39;_&#39; for c in table_name)<br><br>    # Check if the table already exists<br>    if table_name not in [t.table_name for t in conn.cursor().tables(tableType=&#39;TABLE&#39;).fetchall()]:<br>        # Table does not exist, create it<br>        create_table_query = f&#39;CREATE TABLE {table_name} ({&quot;, &quot;.join([f&quot;[{col}] NVARCHAR(1000)&quot; for col in columns])})&#39;<br>        cursor = conn.cursor()<br>        cursor.execute(create_table_query)<br>        conn.commit()<br>        cursor.close()<br><br>    try:<br>        # Insert data into the table<br>        for _, row in df.iloc[1:].iterrows():<br>            insert_query = f&#39;INSERT INTO {table_name} VALUES ({&quot;, &quot;.join([f&quot;\&#39;{str(val)}\&#39;&quot; for val in row])})&#39;<br>            cursor = conn.cursor()<br>            cursor.execute(insert_query)<br>            conn.commit()<br>            cursor.close()<br><br>        # Delete the file after successful processing<br>        os.remove(os.path.join(folder_path, csv_file))<br>        print(f&quot;Successfully processed and deleted file: {csv_file}&quot;)<br><br>    except Exception as e:<br>        print(f&quot;Error processing file {csv_file}: {str(e)}&quot;)<br><br>conn.close()</pre><p>Having achieved a single-click execution, the next step involves scheduling the process via the Windows Task Scheduler using a batch file.</p><pre>@echo off<br><br>&quot;[PLACE YOUR &#39;PYTHON.EXE&#39; PATH HERE]&quot; &quot;PLACE YOUR &#39;PYTHON.PY&#39; PATH HERE&quot;<br><br>pause</pre><p>Open your notepad and paste the above code into your notepad. Save your file as ‘Test.bat’ to make it an executable file.</p><p>Go to Windows Task Scheduler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ye9a5ibzZwvQbbB3sKGRLw.png" /></figure><p>Create a task and name it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*DMcvfvIzD5mPY_PHQ9qoAA.png" /></figure><p>Navigate to the trigger tag and set a schedule for your batch file execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*0Z0S-wnBKOAPj9Bjbd-fbg.png" /></figure><p>Go to the action tag and provide the path of your ‘test.bat’ file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*AtkHymiw8dXa4YTzHkdd3Q.png" /></figure><p>Save the job and this will automate your data-loading process into your landing database.</p><p><strong><em>Psst</em></strong><em>:</em> At this stage, leverage ‘<strong>Data Orchestration</strong>’ and ‘<strong>Workflow Management</strong>’ concepts. Physically segregate the data and scheduler onto distinct servers from the database. Construct a meticulous workflow to regulate the data flow, adhering to advanced data orchestration principles. Additionally, employ ‘<strong>Data Security</strong>’ concepts to meticulously manage permissions, fortifying defenses against unauthorized access to raw data.</p><h3>Data Transformation:</h3><p>Following the data’s loading into the database during the extraction phase, the transformation phase begins, leveraging SQL functions to cleanse and convert the data into an interpretable format. Conduct an initial review of the data to obtain a preliminary understanding. This step offers a broad sense of the data, guiding the necessary interpolation to effectively utilize the dataset.</p><p><strong><em>Psst:</em></strong> This stage involves the application of ‘<strong>Data Wrangling</strong>,’ ‘<strong>Data Profiling</strong>,’ ‘<strong>Data Cleansing</strong>,’ ‘<strong>Data Validation</strong>,’ ‘<strong>Data Ethics</strong>,’ and ‘<strong>Bias in Data</strong>’ concepts. In the realm of real-world data, it is essential to ensure that your data undergoes these checks to construct valuable products from it.</p><pre>-- Skim through the data to make sense of it <br>SELECT *<br>FROM Test.dbo.Test_Data;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*3h7jsS51qSsrGVQGvrftjg.png" /></figure><p>The subsequent SQL query will construct the functions we have identified for cleansing and transforming our data.</p><pre>-- Skim through the data to make sense of it <br>SELECT *<br>FROM Test.dbo.Test_Data;<br><br>-- Analyse how many distinct products are in data<br>SELECT DISTINCT productid<br>FROM Test.dbo.Test_Data;<br><br>-- Create the products table<br>CREATE TABLE products (<br>    productid INT PRIMARY KEY,<br>    productcategory VARCHAR(255)<br>);<br><br>-- Insert 10 categories with random names<br>INSERT INTO products (productid, productcategory)<br>VALUES <br>    (1, &#39;Electronics&#39;),<br>    (2, &#39;Clothing&#39;),<br>    (3, &#39;Home Decor&#39;),<br>    (4, &#39;Beauty Products&#39;),<br>    (5, &#39;Furniture&#39;),<br>    (6, &#39;Sports Equipment&#39;),<br>    (7, &#39;Books&#39;),<br>    (8, &#39;Toys&#39;),<br>    (9, &#39;Automotive&#39;),<br>    (10, &#39;Jewelry&#39;);<br><br>-- Fetch the data from the landing database and transform the data to dump into a Data Warehouse<br><br>-- 1- Create Functions to transform data<br><br>-- Date Cleansing Function<br>CREATE FUNCTION [dbo].[Date_Cleaner]<br>(<br>    @date_raw VARCHAR(100)<br>)<br>RETURNS DATE<br>AS<br>BEGIN<br>    DECLARE @cleaned_date DATE;<br><br>    -- Validate input length and format<br>    IF (LEN(@date_raw) &lt;= 10 AND ISDATE(@date_raw) = 1)<br>    BEGIN<br>        -- Convert input to DATE datatype<br>        SET @cleaned_date = CAST(@date_raw AS DATE);<br><br>        -- Check if the date is within the acceptable range<br>        IF (@cleaned_date &gt; CONVERT(DATE, GETDATE()) OR @cleaned_date &lt; &#39;1900-01-01&#39;)<br>            SET @cleaned_date = &#39;1900-01-01&#39;;<br>    END<br>    ELSE<br>    BEGIN<br>        -- If input is invalid, set it to &#39;1900-01-01&#39;<br>        SET @cleaned_date = &#39;1900-01-01&#39;;<br>    END<br><br>    RETURN @cleaned_date;<br>END<br><br>-- Price Validity Function<br>CREATE FUNCTION [dbo].[TotalPrice_Cleaner]<br>(<br>    @quantity INT,<br>    @price DECIMAL(18, 2),<br>    @totalPrice DECIMAL(18, 2)<br>)<br>RETURNS VARCHAR(50)<br>AS<br>BEGIN<br>    DECLARE @result VARCHAR(50);<br><br>    -- Check if the calculated total price matches the provided total price<br>    IF (@quantity * @price) = @totalPrice<br>    BEGIN<br>        SET @result = &#39;valid&#39;;<br>    END<br>    ELSE<br>    BEGIN<br>        SET @result = &#39;invalid&#39;;<br>    END<br><br>    RETURN @result;<br>END<br><br>-- Ratings Cleaner<br>CREATE FUNCTION [dbo].[Ratings_Cleaner]<br>(<br>    @rating VARCHAR(5) <br>)<br>RETURNS DECIMAL(3, 2) <br>AS<br>BEGIN<br>    DECLARE @decimalRating DECIMAL(3, 2);<br><br>    -- Convert the provided rating to a decimal value<br>    SET @decimalRating = CONVERT(DECIMAL(3, 2), @rating);<br><br>    -- Check if the decimal rating is within the valid range (0.00 to 5.00)<br>    IF @decimalRating &gt;= 0.00 AND @decimalRating &lt;= 5.00<br>    BEGIN<br>        RETURN @decimalRating;<br>    END<br><br>    -- If the rating is outside the valid range, return NULL<br>    RETURN NULL; <br>END</pre><p>This marks the conclusion of our transformation process, which is typically not a straightforward endeavor. The functions associated with these transformations are stored within your database, ready to be utilized. They function by executing row-wise transformations when invoked in SQL queries.</p><h3>Data Loading:</h3><p>The final phase in a successful ETL operation is the data loading process. This involves either migrating data from existing databases to integrate it with the front end by converting it into the specified data structure or constructing a semantic layer for data analysis, with careful consideration of dimensions and fact tables. Currently, our focus is on creating a database for use as a data warehouse and defining a table with a schema designed to facilitate analysis derived from the data.</p><p><strong><em>Psst</em></strong>: At this stage, the database schema selection is pivotal. The ‘<strong>Star Schema</strong>’ is conventionally utilized for data warehousing, while the ‘<strong>Snowflake Schema</strong>’ is applicable in scenarios necessitating ‘<strong>Data Normalization</strong>’ to mitigate ‘<strong>Data Redundancy</strong>.’ Conduct ‘<strong>Data Modeling</strong>’ to precisely define the structure and formulate ‘<strong>Dimension Tables</strong>’ for provisioning ‘<strong>Fact Tables</strong>.’</p><p>Create a database with the name ‘Test_DataWarehouse’ and Create a table in that database using the following SQL query:</p><pre>USE Test_DataWarehouse<br><br>CREATE TABLE Test_Analysis_Data (<br>    ID INT PRIMARY KEY IDENTITY(1,1),<br>    CustomerID INT UNIQUE NOT NULL,<br>    ProductCategory VARCHAR(255),<br>    [Date] DATE,<br>    Weekday VARCHAR(50),<br>    Quantity INT,<br>    ProductPrice DECIMAL(18, 2),<br>    TotalPrice DECIMAL(18, 2),<br>    Rating INT<br>);</pre><p>After making the table, we need to change the raw data to make it useful. To do this, use a simple naming style, get data from the starting database, and put it into your data warehouse. Follow the steps in the query below to put the data:</p><pre>    INSERT INTO [Test_DataWarehouse].dbo.Test_Analysis_Data (CustomerID, ProductCategory, [Date], Weekday, Quantity, ProductPrice, TotalPrice, Rating)<br>    SELECT <br>        CustomerID,<br>        b.ProductCategory,<br>        dbo.[Date_Cleaner]([Purchase Date]) as [Date],<br>        DATENAME(dw, dbo.[Date_Cleaner]([Purchase Date])) as [Weekday],<br>        Quantity,<br>        [product price],<br>        [total price],<br>        dbo.[ratingas_cleaner](Rating) as rating<br>    FROM Test.dbo.Test_Data a<br>    JOIN products b<br>    ON a.ProductID = b.productid<br>    WHERE dbo.[TotalPrice_Cleaner](quantity, [product price], [total price]) = &#39;valid&#39;;</pre><p>To streamline the loading process and enable one-click execution, it is imperative to create a ‘Stored Procedure’ dedicated to executing the insertion query. Utilize the provided query below to craft the Stored Procedure:</p><pre>USE TEST<br><br>CREATE PROCEDURE InsertIntoTestDWH<br>AS<br>BEGIN<br>    INSERT INTO [Test.dbo.Test_DataWarehouse].dbo.Markaz_Final (CustomerID, ProductCategory, [Date], Weekday, Quantity, ProductPrice, TotalPrice, Rating)<br>    SELECT <br>        CustomerID,<br>        b.ProductCategory,<br>        dbo.[Date_Cleaner]([Purchase Date]) as [Date],<br>        DATENAME(dw, dbo.[Date_Cleaner]([Purchase Date])) as [Weekday],<br>        Quantity,<br>        [product price],<br>        [total price],<br>        dbo.[ratings_cleaner](Rating) as rating<br>    FROM Test.dbo.Test_Data a<br>    JOIN products b<br>    ON a.ProductID = b.productid<br>    WHERE dbo.[TotalPrice_Cleaner](quantity, [product price], [total price]) = &#39;valid&#39;;<br>END;</pre><p>Enable the scheduling of this Stored Procedure for execution at a designated time by constructing an SQL job. This job will execute the stored procedure and facilitate the insertion of data into our data warehouse. To establish an SQL job, follow the outlined steps below.</p><p>Go to the jobs tab and create a new job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*5v1SBDFxeeHEvCjPDGWBXw.png" /></figure><p>Give your job a name and description, if required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*Scu6HmTa6dBEFyVHXaqdYA.png" /></figure><p>Generate a new step and assign a name to the step. Since this task necessitates access to your Stored Procedure (SP), utilize a database housing the relevant stored procedure. Employ the integrated ‘EXEC’ functionality to execute the Stored Procedure, and input the corresponding command in the command box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*CA60JdM2kB95DQqx4cjHPw.png" /></figure><p>Navigate to the ‘Schedule’ tag and establish a schedule for the Stored Procedure (SP) execution based on your specific requirements. Upon selecting your preferred time, the chosen schedule will be presented in a statement below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*aHOjTDvP3tBvIMZYKkDqkw.png" /></figure><h3><strong>Conclusion:</strong></h3><p>The presented workflow offers a comprehensive overview of our automated Extract, Transform, Load (ETL) process, aligning with fundamental data engineering principles. The entire data pipeline, encompassing extraction, transformation, and loading, is fully automated. While the constructed pipeline is capable of efficiently migrating substantial volumes of data into the designated database, it is crucial to acknowledge the inherent complexities associated with managing big data.</p><p>This project serves as a valuable resource for individuals commencing their careers in data engineering, providing a substantial understanding of the intricacies involved in the data engineering process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ze12QXpuM4khVAc_QNB_zg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68e014d9eea9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analytics: Oppenheimer’s Atomic Symphony: A Journey through the Explosive Era of Bombings]]></title>
            <link>https://medium.com/@hassaan.yousaf1025/oppenheimers-atomic-symphony-a-journey-through-the-explosive-era-of-bombings-740e76155713?source=rss-eecffbd0fdc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/740e76155713</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[world-war-ii]]></category>
            <category><![CDATA[atomic-bomb]]></category>
            <category><![CDATA[oppenheimer]]></category>
            <dc:creator><![CDATA[Hassaan Yousaf]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 13:43:00 GMT</pubDate>
            <atom:updated>2023-12-01T13:57:08.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImmaL2c0AKelMPmepIgaHg.jpeg" /></figure><blockquote><strong><em>A Symphony of Destruction</em></strong></blockquote><p>When you hear the words “atomic bomb,” images of Hiroshima and Nagasaki immediately spring to mind. However, there is a lesser-known, yet equally devastating, bomb attack that takes the title of the deadliest ever — the bombing of Tokyo during World War II, codenamed “Operation Meetinghouse.”, in which, over 300 B-29 Superfortress bombers unleashed a torrential rain of fire on the Japanese capital. The resulting firestorm engulfed the city, leaving an estimated 100,000 people dead and over a million homeless in a single night.</p><p>This era was a turbulent symphony of bombs raining down from the sky, and in this article, we will delve into the chilling statistics of these demonic bombings and their profound connection to the development of the world’s most dangerous project: the Manhattan Project. As we embark on this visual journey, we will explore the geopolitical landscape, the political and psychological motivations of those involved, and the simultaneous destruction unfolding across the globe and how this symphony of bombings made these all significant figures dance around. The dance where every move decided the fate of souls around the globe.</p><p>Brace yourself for an eye-opening exploration of the dark depths of human history, where politicians and scientists alike propelled themselves toward the creation of a weapon capable of extinguishing humanity itself.</p><blockquote><strong><em>Unveiling the Interactive Dashboard: Witness the Reign of Destruction</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2_cZMfibj1nECtAlLtbTA.png" /><figcaption>Image of visualization</figcaption></figure><p>Behold! A sneak peek into our captivating interactive dashboard, where you hold the power to adjust the date and country, unveiling the true scale of devastation inflicted upon unfortunate soils. Scroll down and immerse yourself in a captivating historical narrative that revolves around the events entwined with the Manhattan Project. Step into the shoes of Oppenheimer and all the other figures involved in this project, torn between the agonizing dilemma of creating a weapon of unfathomable power or witnessing the world burn before his very eyes.</p><p>With a simple adjustment, you can visualize the daily bombardments, grasping the sheer magnitude of destruction unleashed upon a weary world. Discover the top five industries that were ruthlessly targeted, as the number of bombs dropped upon them offers a chilling glimpse into the calculated strategies employed during wartime. Moreover, the diverse range of bomb types used speaks volumes about the dark intentions of scientists, seeking to inflict maximum damage upon their adversaries before the inevitable reckoning befalls them.</p><p>Prepare yourself for an immersive experience that will transport you back to an era where the fate of humanity hung in the balance. Our interactive dashboard will leave you pondering the immense moral dilemmas faced by those responsible for shaping the course of history. Are you ready to unlock the secrets concealed within this symphony of destruction? <a href="https://app.powerbi.com/groups/me/reports/1215bd59-05d8-45ea-b3fd-fb6c56093aad/ReportSection?experience=power-bi&amp;bookmarkGuid=Bookmark650e46704a5d18a47e1f">Click on the link and Step right in and witness the chilling reality that shaped our world forever.</a></p><p>Don’t Forget to read visualization descriptions as they give you the actual overview of the world on respective event time zones.</p><blockquote><strong><em>Embarking on the Odyssey</em></strong></blockquote><p>With anticipation building, let us embark on this odyssey through time and delve into the events that shaped our world. Interact with the visualization before you, unlocking the power to dive deep into each momentous occasion.</p><p><strong>World War II Begins <br>01/09/1939</strong></p><p>As the curtain rises on the global stage, World War II emerges as a tempest, engulfing nations and forever altering the course of history. In this pivotal moment, we glimpse into the lives of key figures who would shape the destiny of the Manhattan Project. Let us explore the states of these remarkable individuals as the war begins:</p><p><em>Leslie Groves (Played by Matt Damon in the Oppenheimer Movie):</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ww2b_RMcBloqxz3sKlf9fQ.png" /><figcaption>Leslie Grove (First) Matt Damon (Second)</figcaption></figure><p>A seasoned military leader, General Leslie Groves is tasked with overseeing the Manhattan Project. With a reputation for efficiency and discipline, Groves brings military precision to the project’s operations. As a bridge between a deadly project and the inferno of war, every fateful decision flows through him.</p><p><em>Lewis Strauss (Played by Robert Downey Jr. in the Oppenheimer Movie):</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gPvOuRze3RvRtaqiSGhGkg.png" /><figcaption>Lewis Strauss (First) Robert Downey Jr. (Second)</figcaption></figure><p>Enter Lewis Strauss, a man of business and politics, a pivotal figure shaping the project’s future. His influential connections and keen understanding of politics support navigating bureaucracy and securing resources. He adeptly shields Oppenheimer, ensuring focus on the development of a soul-consuming demon.</p><p><em>Harry Truman (Played by Garry Oldman in the Oppenheimer Movie):</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHqrzilMxKZ0zRF3-EQU-Q.png" /><figcaption>Harry Truman(First) Garry Oldman (Second)</figcaption></figure><p>Destined for a pivotal role, Harry Truman serves as Vice President under President Roosevelt. Little does he know that the weight of the world will soon rest upon his shoulders. Truman’s journey from Vice President to becoming the President who ultimately makes the fateful decision to use the atomic bomb will define his legacy and forever alter the course of human history.</p><p><em>Albert Einstein (Played by Tom Conti in the Oppenheimer Movie):</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBEdcicR0onLGEy4HyMxXg.png" /><figcaption>Albert Einstein (First) Tom Conti (Second)</figcaption></figure><p>Renowned physicist Albert Einstein, casts a long shadow over the scientific community. His groundbreaking theories on relativity and the relationship between mass and energy laid the foundation for the development of atomic weapons. His letter to President Roosevelt is what triggered the development of Manhattan Project.</p><p>In the tumultuous backdrop of World War II, these individuals, each with their unique histories and present states, find themselves inexorably linked to the Manhattan Project. Their stories intertwine, setting the stage for an unprecedented scientific endeavor with far-reaching consequences.</p><p><strong>Plutonium Discovery: Unleashing the Power Within<br>23/02/1941</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*NYRwr0yCcfg3FlmUTTSmAw.jpeg" /><figcaption>Lawrence Berkley National Lab; where plutonium was discovered.</figcaption></figure><p>Amidst the escalating horrors of World War II, with the Germans relentlessly advancing across Europe, a pivotal moment emerged in February 1941. Glenn Seaborg, Edwin McMillan, Joseph W. Kennedy, and Arthur Wahl achieved a groundbreaking discovery — plutonium. The world stood on the brink of destruction, and the ethical weight of their work weighed heavily on their minds, much like Oppenheimer’s. The destiny of the Manhattan Project and the fate of nations hung in the balance as they navigated the complexities of harnessing nuclear power.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-CpxXjQfJRXbmNq4QO97g.png" /><figcaption>War is confined to Europe but reaches Africa as Ethiopia wins back its freedom from Italians with the help of British Commonwealth Forces.</figcaption></figure><p><strong>The Dawn of Power: Roosevelt Authorizes the U.S. Atomic Bomb Project<br>9/10/1941</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*Zljt5-NqmLopC5ZluJJOoA.jpeg" /></figure><p>Amidst the harrowing horrors of World War II, the global conflict intensified with the relentless advance of the German forces. On October 9, 1941, a pivotal moment arose as President Franklin D. Roosevelt took a momentous step, authorizing the development of an atomic weapon. This historic decision marked the official commencement of the U.S. atomic bomb project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1r35LMbS1TxPyeTeZaOO9Q.png" /><figcaption>War intensifies in Europe, with France now being attacked by British Royal Air Force</figcaption></figure><p><strong>Unleashing the Atom: The Birth of the Manhattan Project<br>13/08/1942</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyVvQcPNBKtZicXGVCaJGQ.jpeg" /><figcaption>Manhattan Project site, now a National Park</figcaption></figure><p>In the midst of the escalating chaos and devastation of World War II, August 1942 marked a critical turning point. As the German war machine continued its relentless march, the urgency to find a scientific breakthrough became more pressing than ever. It was during this dark hour that the Manhattan Engineering District was established — a secretive initiative dedicated to harnessing the power of atomic energy for warfare.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4iaBmfmzh9_XFwL0mpFIg.png" /><figcaption>Amidst the escalating war, Japan’s imperial ambitions led to attacks on Myanmar and psychological warfare on Australia and divert the allies to defend Australia. Meanwhile, Allied forces launched counteroffensives, reclaiming Japan-occupied territories.</figcaption></figure><p><strong>Forging the Path: Leadership Assignments in the Manhattan Project<br>23/09/1942</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kojby4Rmmhhd3__lvCE1nA.jpeg" /><figcaption>Oppenheimer (Left), Leslie Grove (Right)</figcaption></figure><p>In September 1942, amidst the raging war, pivotal leadership assignments shaped the trajectory of the Manhattan Project. Colonel Leslie Groves assumed the mantle of director, charged with overseeing the immense logistical and administrative challenges of the ambitious endeavor. Alongside him, the brilliant mind of J. Robert Oppenheimer took on the role of scientific director, guiding the project’s scientific pursuits.</p><p>Their collaborative efforts formed the backbone of the Manhattan Project, as they navigated through uncharted territories of nuclear research, confronting unprecedented ethical dilemmas with each step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zf6blbhnl7NCCK0UtYFKhA.png" /><figcaption>War further intensifies with the average number of bombs dropped per day increasing from 120 to 135 in just one month!</figcaption></figure><p><strong>A Breakthrough Unleashed: The First Controlled Fission Reaction<br>2/11/1942</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*REyaKLC8ZuFog9fnCkQUMA.jpeg" /><figcaption>Los Alamos Lab, birthplace of Atomic Bomb</figcaption></figure><p>Amidst the escalating horrors of World War II, at the end of 1942, as Germany’s forces occupied vast territories and the death toll rose, Enrico Fermi achieved a momentous breakthrough on December 2. The Chicago Pile-1 experiment marked the first controlled nuclear fission reaction, igniting the path of atomic science. The Manhattan Project surged forward, embracing the promise of scientific progress amid the ethical complexities that lay ahead. In this crucible of war, the fate of nations hung in the balance, forever changed by the transformative power of controlled fission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdUYCPpCJfiCSwwekQDAhg.png" /><figcaption>Stalin promises that the enemy “will yet feel the weight of the Red Army’s smashing blows.” as Germans are ordered to “Stand and Die” by Hitler while attacking Stalingrad.</figcaption></figure><p><strong>Japan as the Chosen Target: The Manhattan Project’s Decision<br>5/5/1943</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*P4oOXamiMxaWwmLcEptJYg.jpeg" /></figure><p>In May 1943, amidst the escalating war, the Military Policy Committee of the Manhattan Project made a historic decision. Deliberating carefully, they identified Japan as the primary target for potential atomic bomb deployment. This choice was driven by Japan’s crucial role in the war, particularly its tenacious resistance and expansion across the Pacific, and the war dying out in Europe as Hitler faces defeats at many fronts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZhhre82sWM0KRnTO-QR8A.png" /><figcaption>The Japanese resistance can be seen as bombing intensified around Japan’s outskirts, doubling the average daily bomb dropped.</figcaption></figure><p><strong>Victory in Europe<br>8/5/1945</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*0_ENUpqnokp9lwS1yxIe_w.jpeg" /></figure><p>Victory in Europe was triumphantly celebrated on May 8, 1945, as Germany’s surrender marked a significant turning point. The world, however, could not rest, for the relentless resistance of Japan cast a shadow of uncertainty over the Pacific theater.</p><p>As the world prepared for the grand finale, the legacy of Oppenheimer and his colleagues intertwined with the destiny of nations. With the stage set, the world awaited the crescendo, where the decisive clash with Japan would bring the inferno to its conclusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgxwfBj4vTOxzhEPcbpB7w.png" /><figcaption>Hellfire rained across the globe, yet the true inferno awaited Japan.</figcaption></figure><p><strong>The Trinity Test: Birth of Atomic Power<br>16/7/1945</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*mLXv505M7MZEDDTk_pp5Ug.jpeg" /></figure><p>On July 16, 1945, a defining moment in history unfolded as the world bore witness to the Trinity Test at Alamogordo, New Mexico — the first-ever atomic detonation. The earth trembled, and the sky ignited in a brilliant flash of light, as Oppenheimer’s vision and the Manhattan Project’s relentless pursuit of scientific progress culminated in a groundbreaking achievement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPNlvuXtbS2wrW879l9etg.png" /><figcaption>There is not much data available on target places but by this time, American bombers had flatten cities with incendiary bombs, creating firestorms and bringing hell on Japanese people</figcaption></figure><p><strong>Rejected Declaration: The Cataclysmic Prelude to Atomic Power<br>28/7/1945</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrMAlioI6fQ1uyLH6mqt2Q.jpeg" /><figcaption>Leo Szilard</figcaption></figure><p>In May 1945, physicist Leo Szilard sought to personally warn President Truman about the dangers of atomic weapons, urging caution in their use. However, American intelligence revealed that Japan would only accept “unconditional surrender,” posing a significant obstacle to achieving peace through diplomatic means.</p><p>President Truman, on July 21, 1945, authorized the use of atomic bombs, targeting four cities; Hiroshima, Nagasaki, Kokura, and Kyoto. Amidst escalating tensions, the Potsdam Declaration, issued on July 26, 1945, demanded Japan’s unconditional surrender, threatening “prompt and utter destruction” if their terms were rejected. Japan’s refusal to surrender on July 28, 1945, further escalated the possibility of atomic bombings.</p><p><strong>Nuclear Nightfall: Japan’s fateful Encounter<br>6/8/1945</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1puoXRDsWKKc1Xj_V6kISg.jpeg" /></figure><p>On August 6, 1945, the uranium bomb “Little Boy” was unleashed upon Hiroshima, leaving in its wake immense destruction and a heart-wrenching loss of life. A day later, on August 7, 1945, the United States dropped warning leaflets over Japanese cities, signaling the impending threat of further atomic bombings. As tension mounted, the second atomic bomb, “Fat Man,” found its target on August 9, 1945, over Nagasaki.</p><p>Japan’s will to resist shattered under the weight of such devastation, and on September 2, 1945, the nation announced its formal surrender. World War II came to a close, but the impact of the atomic bombings lingered as a haunting reminder of humanity’s capacity for both destruction and renewal.</p><blockquote><strong><em>Resonating Lessons: Concluding the Symphony of Destruction:</em></strong></blockquote><p>In this symphony of destruction, our visual journey uncovered the chilling statistics of Operation Meetinghouse, history’s deadliest bomb attack, intertwined with the Manhattan Project. At its core, Oppenheimer’s dilemma unfolded, reflecting the haunting moral choices faced. The interactive dashboard immersed us in the relentless devastation, offering glimpses into the souls of those developing the bomb as they witnessed hellfire on earth through their windows. Their desperate hope for salvation hinged on creating a bigger and far more demonic monster to engulf their enemies in its wrath, rather than succumbing to the ominous specter lurking just outside their windows.</p><p>Let the symphony of destruction be a poignant reminder of our collective duty to safeguard humanity and build a world worthy of our potential. As we bid farewell to this odyssey, the decisions we make today will shape the symphony of tomorrow.</p><p>A visual at the end to summarize the whole bombing status in 3 unfortunate eras gives you a zoomed out vision of the bombing in the war.</p><p><strong>Before Manhattan: </strong>Unraveling Tensions in the Gathering Storm of War<strong> <br></strong>[9/1/1939 – 8/13/1942]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*clgNPx0vJN-y4qx-7pyHYA.png" /></figure><p><strong>Oppenheimer’s Epoch: </strong>Igniting the Atomic Age Amidst the Flames of Conflict <strong><br></strong>[8/13/1942 – 7/28/1945]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtvQ51eg637J-mFCJyTtIw.png" /></figure><p><strong>The Surrender:</strong> A Pivotal Moment Unraveling the Last Threads of War [7/28/1945 — 12/31/1945]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTYl4FgoSYTHyChy1ytyAA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740e76155713" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>