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
My favorite part is how you talk through each part of code while you type...absolutely priceless.
I think you're the best Python channel around here! Straight to the point. Amazing work, man. Thanks!
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
3 жыл бұрын
Python and SQL work very well together github.com/ldo/python_topics_notebooks/blob/master/Databases%2C%20Iterators%20%26%20Looping.ipynb .
You do a great job explaining python/how it applies to functional applications in the work place! Great job!
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.
Love your channel, straight forward without any bullshit. You really deserve more subs !
Thank you Derrick cant wait for the next tutorials
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
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.
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
Good video. I look forward to seeing more of your tutorials.
Awesome video! This is something so practical I can use and it's stimulated even more automation ideas! Thanks man!
Great tutorial ! Wanna see the following part.
Awesome as always
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. 👍🏽👍🏽👍🏽
good series!! waiting for the next video! 😁👍
Love this script! Thanks Derrick! :)
Derrick-san we were worried u were gone thanks for all the awesome vids keep it up
It is so great, thanks!
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.
Excellent. Thanks
Great work keep it up
Amazing tutorial 👍👍👍
Long time Derrick! Seen your last videos over 5 mo ago. Hope you are back and stay publishing videos regurarly!
You teach very well. Please continue to make more videos :)
Wowww I like this tutorial, and I like that you tell us what we need to install 😫
Nice!
Thank you so much
Excelente. 👏👏 very good 👉🔔
i like your style, bought your course on udemy, hope it is as good as these vidoes.
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.
Where have you been bro Dope video btw! 👍
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 ...
This guy is smart.
Thank you ¡¡¡¡¡¡
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?
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
Amazing Make a video on making personal chabot using NLP
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
Great tutorial ! Can you please start django tutorial.
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
You could go for `file_list = [file for file in os.listdir(data_location)]` to simplify your code a little bit
@lawrencedoliveiro9104
3 жыл бұрын
Or just file_list = os.listdir(data_location)
@Derrick Sherrill could explain how to get excel smart table into pandas dataframe?
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
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?
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!
There's any program i can make to list all the files on my computer to a excel spreadsheet?
I better review more basic videos first. 😅.. Great effort by tutor, hence the like 👍
like!
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
Hey there can we automate outlook to send mail but there is 2FA so can you please suggest how to do that
If I have putty server I want to download file every time and upload to one drive . So we automate this
9:52 I would use os.path.join(directory_to_search, file) here.
I'm new to python where are the brackets
Hey i think you will get error while reading excel file in windows with same code. I wonder what is the solution.
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
4 жыл бұрын
I would recommend just asking the IT team. I had the same worries when I was writing code with VBA.
Zero dislikes wow
Notice he uses slashes “/” instead of backslashes “\” for the path separator. Python supports Linux/Unix-style “/” path separators even on Windows!
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
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
First, I need to know, how to get python installed on my work computer? Can anyone help please
@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
CAN YOU MENTOR ME PLEASE I'M A BEGINNER