5 Amazing Ways to Automate Your Life using Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so in this video I'm gonna be sharing with you five a very quick python automation project that you can finish in literally one weekend to hone your skills and help you become a real python developer this series on python automation has been wildly popular on my channel and I think for good reason because I think you guys are realizing by now is that to be a real developer you don't want to be building a Mickey Mouse projects like most people do the thing that employers look for and what differentiates a coder from a real developer is the ability to apply your coding skills to real world problems and what better way to get started with this than to build projects using python to literally automate your life and build yourself an army of minions to do boring tasks for you that is exactly what we are learning in this video alright so the first thing we'll be looking at is being able to use Python read and manipulate the csue files taking in data and having the skill of being able to read and manipulate it using python was one of the most common things I was was doing and one of the most common skills that you will need to have in your Arsenal as a developer excuse me python you will have access to a library called CSV which you can import using the normal import statement using Python and for this example we're writing a simple finance manager where I'm basically taking a CSV file of transactions which I've got right here and then the goal is to extract the information that we actually care about like for example the date the name and the amount of the transactions not have to deal with all of these things like transaction IDs and a lot of this other stuff that you really don't care about what we're going to do is Define this function called finance manager which is simply going to take in a file name we're going to start off with a sum that's initialized to zero because what we're going to want to do is to actually sum the transactions from the entire month and then the crucial function that we need to use is provides with open with the file and then mode is going to be R which means read so we only want to be reading the file rather than writing if we wanted to write something in into the file you would use W over here we're going to go R then as CSV file and we're going to initialize a variable called CSV reader by calling CSV a DOT reader and the CSV file inside of it and we're going to give the CSV file as a parameter now the CSV reader is basically a reader that allows us to read this file and do a bunch of things to it from the CSV Library so this is what we're going to be using most of the time we're going to skip the header by calling it next because basically in this file we have this header file that we don't actually want because this is not an actual transactions we we're just sort of storing it here even though we're not going to use it because we just want to skip over it so that when we start looping over these rows using this for Loop over here we're not going to be going over the header file at all then what we want what what I want you might be interested in some other information I just want the name and the amount of the currency and then I'm going to go to the file and look at which of these columns are the things that we want so it's going to be index number one index number two three four and index number five six seven I believe then we're gonna create this transaction Tuple using these variables that we just got from the file and we're gonna add to the sum the amount of the transaction then to this transactions list which should probably actually be defined somewhere in here so we initialize we're going to just append the transaction itself and at the end we're gonna print the sum of what the transactions is whatever it is we're going to print an empty line and then we're gonna return the transaction and at the end we're gonna try running this actually this is just an F string without worrying if you're not familiar with this you could literally just go uh one though then just input the file like this and when we run this we will get the sum of the transactions was this much and these are all the transactions we had if you're interested in doing something with csvs I will leave all of this code down below that you can use as a starting point and then based on what you want to create based on what's interesting to you you can use these same Concepts to do a lot more thing for example the startup that I'm building right now is a personal finance app where I'm essentially using a lot of these same functions a lot of these same tools to taking CSV transactions from the users and then send that data in the format that I want based on my app to allow me to then visualize it for the user in different kinds of ways so that's just an example of a real world use case for these skills with that let's move on to the next one the project number two is a desktop cleaner basically if you've ever been in a situation where your desktop looks like this then this is going to be an interesting project for you I've defined several different paths to different folders based on the type of file that I want to be sent to these different folders Now define a source directory which is going to be in my downloads folder this would be your desktop or whatever and then I've defined these lists which I'm going to leave down below in the code section for different file extensions based on the file type so we know that every file type that has one of these extensions is going to be an image everyone that has one of these extended is going to be a video and then we have this unclean function which is the main function this function is going to run and then with scanner with the source directory as entries this function in here which we have imported from the OS library in Python is going to actually take every file in this directory and it's going to return it to you as a list and then we're going to Loop through that list with a for Loop get the name using entry dot name and you would find how to do this in the documentation and everything like that and then we're going to run this function called check audio check video check image files and check document files and all of these are basically functions to check whether that file is a video or an audio or an image or a document file for example for this one it's going to look through all the extensions in the video extensions list it's going to check whether the name ends with the extension to determine whether it's a video file or not and if it is it's going to run this move file function which is going to move that file into the video destination folder which we have simply defined for us right there and the move file function simply looks like this first you can check whether that file already exists if it does it's gonna do the function to like make the name unique and a bunch of stuff that's like not that important and then after that it's going to run the move function which is simply a function that is imported from the shuttle library that is how that project work and then I have a more complicated version of this that I actually use in my literally everyday life a full tutorial on that on my channel but basically you can expand this to have this be running automatically at all times and then automatically whenever something goes into my download folder it's gonna run this and it's going to move it to the correct folder it's pretty cool once you learn to do this I actually had this on my GitHub and it becomes sort of an open source project a lot of you have been helping me with this just bear in mind if you watch the tutorial it's a pretty old video so the version I have there is not quite as optimal as it could be with that let us move on to project 3 in email sender this is also going to introduce us to apis and the API that I use to send emails and something called mail gun let's go on here you get I believe yeah 5 000 emails a month for free you would go and click on get started for free and then you will get an account and the easiest way for you to get started you're sending an overview then click select API uh you're gonna get this starter code like you'd literally just copy it and this is essentially going to allow you to use it but I just did it my way uh you copy this line from here as a variable inside your program and then you'll find your API key which you can get by clicking on API keys on here and you would copy from here and then I believe you need to go and add yourself as a verified user for basically to allow you to send yourself emails and you would do that by clicking on here and just entering your email addresses and then saving it by the way with your API key make sure to never show it to anyone because these are private and definitely never broadcast it to tens of thousands of people online anyway this will be my API key right here then we will Define the function called send email takes in the to email subject and the body which we Define down here and then we run the function with those and here we created this data object and you'll find how to use this on all of these by simply going in to the mail gun documentation we're going to define a response object which is going to be a post request with this is going to actually send that post request and it's going to check whether the status of the response is 200 meaning it was successful it's going to print that the email was sent successfully otherwise if there's something wrong with the network or something it's going to give you an error and if we try that and I go it looks like you succeeded and I go to my email and it works amazing stuff next we have a Google Drive a bulk uploader so basically if you have a bunch of files and you want to upload them to Google Drive and doing that and bringing them into the correct folder is going to be pretty annoying to do manually so why don't we just let python do it for us I've made this program for us and for this we're using the Google Cloud API I would recommend you go actually read about it and the basics of how it works basically a lot of this code right here is directly from the Google Cloud documentation so basically this function here basically just creates a connection between us and the Google cloud and before this you would have to go on something on Google Cloud console you would create an account on here then it would go on to your projects up here you'd go on apis and services search for Google Drive you can click on enable to actually enable the ability to use Google Drive API and it would go hover over all the apis and services click on credentials click on create credentials oauth client ID basically just go through some of these fields and then eventually you would be able to download this Json file which has a bunch of credentials for you to actually allow you to manipulate Google Drive and all the stuff using your python code you would save it in the same folder as your program with the name of credentials.json to make this exact function to create the connection which is going to return credentials to actually allow you to then start doing a bunch of cool stuff and this other function here is actually going to do the task of uploading a file from your computer to your Google Drive and then this function here is going to be the outer function that we run you're going to take the path to the directory it's going to get the files using OS dot list there and then it's going to Loop over those files and for all of them he's going to run the upload file function which basically first creates a service with Google Drive and then it tries to do a bunch of stuff to actually do it and like the details of this is going to be the Google Drive API documentation and at the end it's going to do it if there's an error it's going to return this except course right here oh and by the way last thing you would need to find is this folder ID which you would go to your Google Drive you would go on Google Drive and you would open the folder that you want your files to be uploaded to and then the folder ID is basically in your url is going to be in this string of text right here of the the folder slash you're going to copy this into your code and then basically as long as you have to find the correct path to upload stuff from which for me is this one we're gonna now run this to see if it works hopefully I didn't make any stupid mistakes and voila it is right there isn't that magical if it is magical hit the like button and last but not least we have an investing return calculator or like a wealth tracking calculator essentially this is something that I personally find pretty cool because I'm really into personal finance and the software app the software startup that I'm using is a personal finance startup so that's why a lot of these examples are based on Personal Finance basically whenever you have savings let's say you're saving five thousand dollars a month and you invest it based on the return and the rate of return of your investment you can calculate how much money you're going to have over a certain period of time basically we have two different programs in here we have calculated wealth by year so it's going to take in your current wealth current rate of return that you expect how much you're saving per month and for how many years you wanted to calculate your wealth based on these numbers obviously this is going to change over your life and stuff but this is going to give you an idea of what's possible so we're gonna first taking total savings we're just gonna be initialized to the current wealth and then four years from one till the year that you chose plus one you're gonna calculate interest and it's gonna add the interest to the total savings and at the end of it it's gonna print it's gonna print the total wealth at the end of each year so if you run this is first going to ask us to choose the program I can choose return a current well let's say have ten thousand dollars let's say I have a seven percent return four thousand dollars a month and we're gonna cover it for 20 years basically this is pretty incredible even at this kind of savings rate at the end of 20 years I would have more than two million dollars by the looks of it and then we have this other function which is gonna allow you to calculate how many years you're gonna have to spend in your life until you are financially freeze which basically the answer to the question of how much money would you need to live off for the rest of your life without having to work which is my personal goal right now it's just gonna run an infinite Loop and it's going to keep adding the interest of the savings until we reach more than our Target wealth or if we run this program I'm going to move that a bit current well let's say we have ten thousand dollars doesn't return let's say I'm saving again four thousand dollars and I and then I need five hundred thousand dollars to be financially free let's say that's my number it will tell me it will only take me eight years to be financially free even at the savings rate which is pretty incredible and the way I'm doing this thing where it's choosing the programming stuff basically I'm gonna use this input function I'm first gonna ask the user which of these two programs it wants to run if they choose to run the return it's going to run the return function if they choose Freedom it's gonna ask still for the Target well and then it's gonna run the calculate year still Freedom function right here and actually this is only relevant in here so we're gonna put that there and basically yeah it's just asking for those variables simply using the input function sooner than the costing functions to make the strings in the floats and yeah so if you're in a situation where you maybe you watch this video and you're feeling like you're not quite confident enough in your coding abilities to maybe go out there and create something like this on your own or you watch this and you're like okay what does that function do why did you choose this what did he call that thing like that if that is you and you want to actually Master the Python programming language you might be interested in my new program python developer masterclass where I break down the skill of programming into its constituent part and teach you programming in a way that you will actually understand and learn very logical way and you will have this whole new part of your brain that actually understands how programming Works under the hood the program I have with most quoting courses is they focus too much on syntax and just like memorizing these random functions without actually taking the time to actually explain what is happening under the hood why are we using these things what do you actually need to know what do you not need to know so that is why I developed the program it's designed specifically to teach you the foundations of programming combine it with lots and lots of practice and I also include 10 ideas for actual portfolio projects that have been proven to get people jobs in the past because I'm going to be honest even if you take the course and all you do is watch the videos and you don't do any of the practice that I tell you to do you're not going to learn coding I'm not going to give you fluff I'm going to give you all the skills and all the support that you need to go from even completely zero to actually being a real developer and understanding the character traits the actual real developers need to possess from my own experience of being a professional and seeing what makes a good developer in the real world I've also expanded the course with a full notion based python developer Playbook with exercises extra materials summaries of the core content three developer roadmaps to get hired and full guides to make your CV to apply for jobs and to prepare for interviews and a lot more so this and a lot more is what you get right now but in fact I am constantly working every single week to develop further the content of further modules there's going to be modules on web development there's going to be modules on object oriented programming and the one that I'm developing right now that I'm most passionate about a full module on python Automation and scripting so given everything that you'll be getting here the price of the program will be 200 and probably even more in the future but right now because some of these modules are still up and coming you have the last chance ever to get this program for only 79 first of all as a thank you for supporting the course early I'm planning to sell the program in other places as well beyond this channel but this discount is something that I'm only releasing to you guys to viewers of my channel basically you could go and do what's in the course now and by the time you finish it some of these other modules are already going to be out anyway so this is really the best deal that you'll ever get on this program so if you've listened to this and it sounds interesting to you but you're worried that you're gonna spend your money and not get value from the course that is why I offer a 30-day money-back guarantee I only want your money if I was truly able to serve you a lot more value than what you paid for this is going to be a link down below for you to check it out but this discount is only available for the next seven days and after that you will never have the chance again to get it at this price point so that is my page I hope you enjoyed the tutorial I don't know why I stopped making this like this Series has been so successful on my channel I think I want to make more let me know Down Below in the comments if you want to see more tutorials like this I'm gonna link the full playlist down below and for now I recommend you go check out this tutorial it's been the second most successful video on this channel of my lifetime with the model 500 000 views so if you haven't seen it yet clearly you are missing out on a lot so I recommend you go watch this video now go check out the course if that resonates with you and with that remember that you can code a lot more than you think I will see you next time thank you
Info
Channel: Internet Made Coder
Views: 100,948
Rating: undefined out of 5
Keywords: python automation projects, automate the boring stuff with python, learn python, python data analytics, python finance, python csv tutorial, python automation, automate your life, learn python fast, python fundamentals, bash scripting, learn to code, coding projets, coding project ideas, python tutorial, desktop automation, coding tutorial, python 101, how to automate tasks for beginners
Id: QjAHcKPUaFM
Channel Id: undefined
Length: 18min 40sec (1120 seconds)
Published: Sun Mar 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.