Python Automation for Remote Workers Series | Working with Files

Ғылым және технология

Let's do this! Let me know if there's specific repetitive tasks that you perform with your remote/office work. In this one we're taking a look at the building blocks of how to use python for file management on your system.
#python #Automation #tutorial
Support the Channel on Patreon --
/ derricksherrill
Join The Socials --
Reddit - / codewithderrick
FB - / codewithderrick
Insta - / codewithderrick
Twitter - / codewithderrick
LinkedIn - / derricksherrill
GitHub - github.com/Derrick-Sherrill
*****************************************************************
Thanks so much for the continued support. This time last year I was thanking you all for hitting 100 subscribers. Now, we just broke 35k. How crazy. Thank you all so much for the continued love and support of my channel. We've come a long way!
Full code from the video:
import os
from datetime import date
import pandas as pd
data_location = 'Docs/Employee Receipts/'
file_list = []
for file in os.listdir(data_location):
file_list.append(file)
data = {'file_names' : file_list }
file_df = pd.DataFrame(data)
new_file_directory = 'Docs/Processed Receipts/'
today = date.today()
#file_df.to_excel(new_file_directory + 'receipts_sum -' + str(today) + '.xlsx' )
for file in os.listdir(data_location):
os.rename(data_location + file, new_file_directory + file )
string_to_find = 'Derrick'
directory_to_search = 'Docs/Processed Receipts/'
derrick_docs = []
for file in os.listdir(directory_to_search):
with open(directory_to_search + file) as f:
if string_to_find in f.read():
derrick_docs.append(file)
print(derrick_docs)
github.com/Derrick-Sherrill/P...
Packages (& Versions) used in this video:
os
pandas 1.0.5
datetime
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
github.com/Derrick-Sherrill/D...
Check out my website:
www.derricksherrill.com/
If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!
--- Channel FAQ --
What text editor do you use?
Atom - atom.io/
What Equipment do you use to film videos?
www.amazon.com/shop/derricksh...
What editing software do you use?
Adobe CC - www.adobe.com/creativecloud.html
Premiere Pro for video editing
Photoshop for images
After Effects for animations
Do I have any courses available?
Yes & always working on more!
www.udemy.com/user/derrick-sh...
Where do I get my music?
I get all my music from the copyright free KZread audio library
kzread.info...
Let me know if there's anything else you want answered!
-------------------------
Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!

Пікірлер: 67

  • @capitankak
    @capitankak4 жыл бұрын

    My favorite part is how you talk through each part of code while you type...absolutely priceless.

  • @luisribeiro2921
    @luisribeiro29214 жыл бұрын

    I think you're the best Python channel around here! Straight to the point. Amazing work, man. Thanks!

  • @capitankak
    @capitankak4 жыл бұрын

    Hey Derrick - from a 40 year old SQL programmer who also loves python your tutorials are priceless. I’ve used Visual Studio a good amount (all my work is in SQL Server) but your simplification of .py files always has me looking for better ways to automate. Much love and God Bless you’re helping your followers tremendously.

  • @lawrencedoliveiro9104

    @lawrencedoliveiro9104

    3 жыл бұрын

    Python and SQL work very well together github.com/ldo/python_topics_notebooks/blob/master/Databases%2C%20Iterators%20%26%20Looping.ipynb .

  • @johngrimsley8848
    @johngrimsley88484 жыл бұрын

    You do a great job explaining python/how it applies to functional applications in the work place! Great job!

  • @ctackett9510
    @ctackett95104 жыл бұрын

    This right here is what I need in my life right now. I'm a "data analyst" transitioning to System Improvements and deal with an Access Database and a lot of various data and need to find ways to make my life easier. Thanks for this Tutorial.

  • @KaidenXIII
    @KaidenXIII4 жыл бұрын

    Love your channel, straight forward without any bullshit. You really deserve more subs !

  • @watwillwedonext
    @watwillwedonext4 жыл бұрын

    Thank you Derrick cant wait for the next tutorials

  • @orkhanahmadov9963
    @orkhanahmadov99634 жыл бұрын

    Best python tutor thanks so much... What i like about this guy so much is also his Character he friendly informs you about what he will teach you and then starts immediately without making circus

  • @rushas
    @rushas4 жыл бұрын

    Good to see you're back. Great content as always. One other trick I also use in similar cases is to add some 'salt' to file_name using uuid. It is useful if you're collecting files from multiple folders, which may include files with the same name. With adding salt into the name, we can prevent the files to over write existing files with the same name.

  • @sacredinclinations
    @sacredinclinations Жыл бұрын

    Thanks again Derrick you are a very talented teacher and it seems you are blessed with a strong intellect, so strong you inspire with me confidence that the problems you deal with have an easy solution. That in itself is a gift you give through your tutorials. Thanks again I guess you must be busy with other things(1 year since you did a video) -whoever employed you is very lucky to have you. All the best

  • @davidgood5220
    @davidgood52204 жыл бұрын

    Good video. I look forward to seeing more of your tutorials.

  • @ptsdarren6223
    @ptsdarren62233 жыл бұрын

    Awesome video! This is something so practical I can use and it's stimulated even more automation ideas! Thanks man!

  • @izoka1828
    @izoka18284 жыл бұрын

    Great tutorial ! Wanna see the following part.

  • @rangabharath4253
    @rangabharath42534 жыл бұрын

    Awesome as always

  • @abeechr
    @abeechr3 жыл бұрын

    Wonderful, keep em coming! I’d love to see a basic server setup in python. I’m a relatively new javascript dev, but the more i watch the more I love python. 👍🏽👍🏽👍🏽

  • @cursoderobotica
    @cursoderobotica4 жыл бұрын

    good series!! waiting for the next video! 😁👍

  • @YoonWhayChong
    @YoonWhayChong3 жыл бұрын

    Love this script! Thanks Derrick! :)

  • @beaR.agadaemoN
    @beaR.agadaemoN4 жыл бұрын

    Derrick-san we were worried u were gone thanks for all the awesome vids keep it up

  • @jackiefan1914
    @jackiefan19142 жыл бұрын

    It is so great, thanks!

  • @robertpearson2143
    @robertpearson21433 жыл бұрын

    I have a friend who is automating some work and your videos we're perfect to help. One thing that also helped me get them started was Thonny the ide. For beginners it makes getting python super easy to setup and add packages. Anyway thank you and I hope you keep making more Pandas videos. One function that might warrant a video is merge to mimic vlookup in excel but that can be used on large files. Also if you make that video a discussion on left right and inner joins could help a lot of people. One annoying problem that came up was pandas adding a decimal to things like customer numbers. Thanks again and stay well.

  • @claudiosilva7697
    @claudiosilva76974 жыл бұрын

    Excellent. Thanks

  • @mahmoudgamal9835
    @mahmoudgamal98354 жыл бұрын

    Great work keep it up

  • @samvarghese8288
    @samvarghese82884 жыл бұрын

    Amazing tutorial 👍👍👍

  • @tanercoder1915
    @tanercoder19154 жыл бұрын

    Long time Derrick! Seen your last videos over 5 mo ago. Hope you are back and stay publishing videos regurarly!

  • @rohitgird
    @rohitgird4 жыл бұрын

    You teach very well. Please continue to make more videos :)

  • @techsobserver
    @techsobserver3 жыл бұрын

    Wowww I like this tutorial, and I like that you tell us what we need to install 😫

  • @noone370
    @noone370 Жыл бұрын

    Nice!

  • @rulaalsamarie3607
    @rulaalsamarie36074 жыл бұрын

    Thank you so much

  • @Henry_Nunez
    @Henry_Nunez3 жыл бұрын

    Excelente. 👏👏 very good 👉🔔

  • @laffiny
    @laffiny3 жыл бұрын

    i like your style, bought your course on udemy, hope it is as good as these vidoes.

  • @shawnbumgarner5638
    @shawnbumgarner56383 жыл бұрын

    Great video Derrick.....I am working on a windows machine and I did have to change one thing to get it to work: >>> Had to add that encoding line or else it could not ready my text file: with open(directory_to_search + file, encoding="Latin-1") as f: That seemed to do the trick.

  • @nowyouknow2249
    @nowyouknow22494 жыл бұрын

    Where have you been bro Dope video btw! 👍

  • @CarlosMoreno-vw4ir
    @CarlosMoreno-vw4ir3 жыл бұрын

    This is an awesome video, thanks so much Derrick, you are the best!! What about if I need to include in the list of files also the list of files in each directory if there is any in the directory that I'm reading, can this be done? Thanks again ...

  • @akyuvar8121
    @akyuvar81214 жыл бұрын

    This guy is smart.

  • @fernandomendoza756
    @fernandomendoza7564 жыл бұрын

    Thank you ¡¡¡¡¡¡

  • @gt2scale
    @gt2scale4 жыл бұрын

    Great tutorial as usual, thank you! Can a script like this work with PDFs instead of TXT? Can Python read a PDF for the last also?

  • @pingojr4048
    @pingojr40483 жыл бұрын

    Derrick do you have any python script that compare 2 excel files and then print what we have on both files and what files we ha in A but we don’t have in B? Thank you so much for all these videos. GOAT

  • @Ur.Podcast_Buddy
    @Ur.Podcast_Buddy4 жыл бұрын

    Amazing Make a video on making personal chabot using NLP

  • @sebastianrothe
    @sebastianrothe4 жыл бұрын

    hey derrick, cool videos! thx alot :) can you maybe do some videos about how to export xlsx sheets in PDF format? that would be awesome

  • @abhijeetkangle5115
    @abhijeetkangle51154 жыл бұрын

    Great tutorial ! Can you please start django tutorial.

  • @orkhanahmadov9963
    @orkhanahmadov99634 жыл бұрын

    Derrick could you also maybe Caching in python ? i am now learning and working with REST api but i need to implement caching in order to get rid off load in server

  • @Rickrolled5997
    @Rickrolled59974 жыл бұрын

    You could go for `file_list = [file for file in os.listdir(data_location)]` to simplify your code a little bit

  • @lawrencedoliveiro9104

    @lawrencedoliveiro9104

    3 жыл бұрын

    Or just file_list = os.listdir(data_location)

  • @aleksandrshvechkov4453
    @aleksandrshvechkov44533 жыл бұрын

    @Derrick Sherrill could explain how to get excel smart table into pandas dataframe?

  • @alexandergarrido942
    @alexandergarrido9423 жыл бұрын

    Derrick Hi, can You please update a video sbout how groupby data, export to XLSX. and for each groupby create folders with thats group in sheets

  • @satoshinakamoto171
    @satoshinakamoto1714 жыл бұрын

    i think when u opened the file, u should have opened it as read mode , since u have not specifically mentioned it . i am assuming python defaults to read mode when not mentioned?

  • @mitchellcauthron361
    @mitchellcauthron3613 жыл бұрын

    Nice series. As a VBA user, I love working with the file structure. I am trying to evaluate the benefits of Python over VBA! With VBA, there is a pretty solid object and method autofill built in, as well as a decent debugger. I am also a daily SQL user and am used to the fairly specific error message to hint where my mistake is...something like "Line 150, Incorrect syntax near 'T0', Unclosed quotation mark." Is there a good tool in Atom for this? The terminal gives similar info, but I'd love to see it in Atom while coding, or before I execute from the terminal. Any suggestions? Perhaps a custom package? Thanks!

  • @lordrac5
    @lordrac53 жыл бұрын

    There's any program i can make to list all the files on my computer to a excel spreadsheet?

  • @msms3260
    @msms32604 жыл бұрын

    I better review more basic videos first. 😅.. Great effort by tutor, hence the like 👍

  • @lozaran
    @lozaran4 жыл бұрын

    like!

  • @iiaa4064
    @iiaa40643 жыл бұрын

    Is it possible to post what I posted on facebook to the timeline of line? I checked automation tools such as ifttt and zapier, but it seems that I can not do it

  • @AnandSingh-gq8sf
    @AnandSingh-gq8sf3 жыл бұрын

    Hey there can we automate outlook to send mail but there is 2FA so can you please suggest how to do that

  • @AnandSingh-gq8sf
    @AnandSingh-gq8sf3 жыл бұрын

    If I have putty server I want to download file every time and upload to one drive . So we automate this

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91043 жыл бұрын

    9:52 I would use os.path.join(directory_to_search, file) here.

  • @ismannyb8148
    @ismannyb81483 жыл бұрын

    I'm new to python where are the brackets

  • @SahilTla
    @SahilTla3 жыл бұрын

    Hey i think you will get error while reading excel file in windows with same code. I wonder what is the solution.

  • @greenhoodie
    @greenhoodie4 жыл бұрын

    Any security issues with logging in remotely for these ? Noob python here, don't wanna upset the IT guys in the office. ...... Thanks for the video.

  • @JasonMinhas

    @JasonMinhas

    4 жыл бұрын

    I would recommend just asking the IT team. I had the same worries when I was writing code with VBA.

  • @shubhmishra66
    @shubhmishra664 жыл бұрын

    Zero dislikes wow

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91043 жыл бұрын

    Notice he uses slashes “/” instead of backslashes “\” for the path separator. Python supports Linux/Unix-style “/” path separators even on Windows!

  • @battalalzumair4389
    @battalalzumair43893 жыл бұрын

    Could you plz add some demo or an examples for results or what are you doing exactly... its all codes with no examples so please make it simple for us if u dont mind

  • @hibald8351
    @hibald83513 жыл бұрын

    Hi I tried to reach you but there is no email offer to reach can i have your help in my new work that aim so overwelled pls

  • @Vikash0125
    @Vikash01254 жыл бұрын

    First, I need to know, how to get python installed on my work computer? Can anyone help please

  • @houalee9101

    @houalee9101

    3 жыл бұрын

    You will likely be unable to. Reach out to your company or organization's IT department and ask if they will allow python to be install on your work machine. The chance of you being allowed to do that is very slim

  • @weslerseni3923
    @weslerseni39234 жыл бұрын

    CAN YOU MENTOR ME PLEASE I'M A BEGINNER

Келесі