![Stephen Codes](/img/default-banner.jpg)
- 6
- 18 037
Stephen Codes
Canada
เข้าร่วมเมื่อ 27 ก.ย. 2020
Creating pictures in Excel using worksheet cells.
In this video we will use a script that creates/draw pictures in Excel using only the cells (no inserting images).
GitHub link: github.com/steve-codes/picture-to-excel
Excel limitations document: support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
Chapters:
0:00 Intro
0:12 Explaining idea
1:04 Running code
2:20 Code review
9:18 Conclusion
GitHub link: github.com/steve-codes/picture-to-excel
Excel limitations document: support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
Chapters:
0:00 Intro
0:12 Explaining idea
1:04 Running code
2:20 Code review
9:18 Conclusion
มุมมอง: 62
วีดีโอ
Using Python to automate data entry for a website (web bot)
มุมมอง 7Kปีที่แล้ว
In this video, we will create a web bot to enter data from an excel file into a website using the python library selenium. This is the most extensive video I've made so far and the code may seem a bit complicated. I tried my best to explain my process, but I can re-create the process in a mini-series if enough people request it (in the hopes of explaining it more clearly). GitHub link: github.c...
PYTHON: Renaming PDFs using an Excel file and splitting PDF pages
มุมมอง 8332 ปีที่แล้ว
Just a note: a good rule of thumb is to backup your data before making changes to it. If you have a lot of files to change; BACK THEM UP. In this tutorial, we explain how to rename PDFs using an Excel file and also how to split PDFs (moving pages into new PDFs). Code: github.com/steve-codes/Splitting-and-Renaming-PDFs-using-Excel Chapters: 00:00 Intro 00:12 Objective 00:45 Requirments 01:00 Pro...
Python: Renaming PDFs using text inside a document with regex
มุมมอง 2.1K2 ปีที่แล้ว
In this tutorial, we expand on renaming PDFs using regular expressions (regex). This is one of the many examples of using regex, if you have different requirements it will require a different regex expression. I have posted a written explanation of the regular expression used in the video on GitHub. Code (pdf_regex branch): github.com/steve-codes/PDF-rename-V2/tree/pdf_regex Regex101: regex101....
Rename PDFs using text content from a document (PYTHON)
มุมมอง 6K2 ปีที่แล้ว
This tutorial is a response to a comment on the last video asking how you would rename a PDF using the title of the file which is located inside the PDF we are trying to rename. If you would like another tutorial request it in the comments and I will try and get back Github: github.com/steve-codes/PDF-rename-V2 Last video: th-cam.com/video/MkXEfzQMmQ8/w-d-xo.html
Changing PDF file names using python
มุมมอง 1.7K3 ปีที่แล้ว
In today's video I'll show you have to programmatically rename multiple pdf files using python. Github: github.com/steve-codes/python-fileRename
Thanks pro but I try to make one on my website but there is a lot of error can you help me, please give me your email
Nice! I just want to check one field - project numbers - and print the result like make a report. Looks doable 🤓
can u help me, error 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option.
It looks like you are trying to run a powershell script but windows has powershell disabled for security reasons. Out of curiosity did you change your default terminal in the steps at 0:43?
Awesome code ! Thank you !!!
Bro is just insane, thank you so much for this video man
Thank you, Steve. You saved me from manually renaming nearly 400 PDFs. And many more in the future. I'm a trial attorney who handles big medical files that are often unorganized. My RegEx is \d{1,2}(\/|-)\d{1,2}(\/|-)(\d{4}|\d{2}) then I rearrange, pad the pieces, and add a random 3-digit string to make the filename unique to sort and group date-related records.
This is awesome! I remember when I decided to first post these videos I was working a COOP and they had me looking at massive Excel files (12+ tabs & 4000+ rows) for links to other workbooks. When I first started it was done all by hand so I decided to make a Python script to search the Excel files. I remember thinking of other ways I could automate manual processes and I heard from a friend renaming a massive amount of PDFs by hand. That's when I thought to make a video on it. I'm glad it managed to help someone... never thought a trial attorney would be using Python! I've seen people in some of my fourth-year Computer Science classes that didn't even know how to code in it (congrats!), it is a very useful tool that can do so much. Enjoy all that time back :)
good stuff, I'm interested in the mini-series. Do you have a discord server?
Sorry, I'm getting around to replying to some of the comments that have been coming in the last few days. I don't have a discord but maybe that would be something to look into. To be honest I haven't used discord much since I graduated. However, in the meantime if you have a video suggestion I would always be down to investigate it. I did start my full-time job recently but I love to solve these types of problems in my free time so suggest away :)
How to remove pdf page using text content with python? is there tutorial....
what if the dataset isn't just numbers. something like: 4-4-5-r-t-tr-4-4-444
Hey Stephen - i have like thousands of pdf’s in a folder with a difference that like we take your case some pdf’s have Order # basis which we want to rename however some pdf in same folder has Product # instead of order #. So how to rename within the same code? Do or works in Regex?
lmao i actually needed to create a pdf editor recently and thought this was going to be changing the header to a line in the text🤣
Hi Stephen, this works like a dream. But when I try to change the cr_regex line to suit my case it does not work. The text in my file is B/L番号(1) JBX1A12345. I only want the JBX1A12345 so I tried to change to cr_regex = r'(?<=B/L番号(1) )[A-Z]{4}\d+', it shows AttributeError: 'NoneType' object has no attribute 'group'.
You're a G brother! Well fucking done!
I followed line by line and i get File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'fitz'
Hi Martin, did you install PyMuPDF? The command is in the github under "Steps". If you're getting that error it means that library ins't installed.
Hey, I found your other videos super useful. I was wondering if you’d be able to give a quick demo of renaming files given an array of two columns, one old name and one new name? Thanks!
Thank for the nice video, can you suggest how can we modify code if we have multipage pdf and want to extract few pages only, also if pdf is scanned doc.
Hi, Thanks for the comment! Yes, extracting certain pages from a PDF is possible with PyMuPDF. Extracting text from a scanned PDF is doable but the last time I tried to do it not all the text was extracted properly (it depends on the scan quality of the PDF). I took a brief look online and it does look like it could be done with another library (I would have to do more research). Unfortunatly I just started my last semester of University so I'm a bit swamped at the moment with coding projects, so it might be awhile before I can take a better look.
@@stephencodes thank you for reply..
This is awesome man. Nice work. Would it be difficult to edit the code to exclude special characters? It worked perfectly other than instances where I had a "/" in the lookup text.
Hi Michael, Thanks! I think it should be possible. Just so I understand, say I have the following text (I want to extract what comes after orderID): Name: Bob Phone #: xxxxxxxx orderID: XAOP/1232232 Email: string@gmail.com You would only want to extract XAOP1232232? (not including the "/").
Cool!
Bro this was great!
what plugin to display orders.xlsx or *.xlsx in vscode
Excel Viewer by GrapeCity: prnt.sc/boDFbB7aRXhp
@@stephencodes thank's
Thanks so much
I'm getting this error " [WinError 32] The process cannot access the file because it is being used by another process:". Any ideas?
This error was due to problems with indentation. My rename() function was tabbed over one too many placing it under the "with open" block instead of the for loop block. If anyone else makes this mistake, double check that your indentation matches the indentation on line 14 at time stamp 6:46 in the video.
I believe that error happens if you're trying to rename the pdf while it is open. Operating systems have restrictions on how data can be accessed/changed. If one process is reading a file (you having the pdf open) and another is trying to modify an attribute of the file (the python script changing the filename) the operating system won't allow it. If you try opening the pdf in any viewer, like adobe acrobat and try running the script, I think you'll get that same error.
nice video. Can u explain why us using a virtual enviroment and why u nit using pypdf2?
Hi Kick, the reason for using a virtual environment is to keep packages separate for different projects. If we didn't use a virtual environment we would be installing packages globally across the operating system which could cause issues if different projects use different versions of the same package. Another reason is I sometimes mess up installations and it is a pain to try and fix a package that is installed globally (in this case I just re-create the virtual environment). Although I only really used one package I do it more out of habit and convenience. I believe the reason for using PyMuPDF over pypdf2 was because pypdf2 messed up the document structure when grabbing the contents of PDFs. I tried a couple other packages but PyMuPDF was the one that worked.
pls make video on pdf 2 line 3 word
Can you telll me how can i rename on the 2nd element on the file?. example instead of renaming it case 7891223 ill rename it to Larry on the description.
I have a video up that does something like this with regex. If you want to pull a name without using a format structure (grabbing text that comes after a certain word for example), then you may need to use another library. Is this what you're trying to do?
how we do it ? if want to take diif text from pdf like case num , doc number , name and save with this file name for example: using the naming format "C:\...\Case Name\DocumentNumber FilingDate LastName FilingType.pdf." "C:\...\Leal v. Bedel et al\#026 2022-07-02 Staedter Motion for Extension of Time to File Answer.pdf."
Are trying to create file folders in this example? (Leal v. Bedel et al). Another question; is your Case Name, DocumentNumber, FilingData, LastName and FilingType on separate lines in the PDF?This shouldn't be too hard to implement, let me know and I can try and make a video.
@@stephencodes now i want to scrape multiple text from pdf like(name,casenumber) and i want to save like that: c:/stephen/45236476/.pdf
@@greenlight4056 Sorry for another question, I want to make sure I understand what you're saying. I'm a bit confused by your (\)s. Say I have this PDF file: Case name: Leal v. Bedel et al Document number: #026 Filing date: 2022-07-02 Last name: Staedter Filing Type: Motion for Extension of Time to File Answer I wouild first create a folder called "Leal v. Bedel et al": prnt.sc/GLgg2tlZbyvm Then I would save a pdf like so (inside the above folder): prnt.sc/5b1A2OP6YX_y
@@stephencodes yes
@@stephencodes Hi Stephen! could you please make a video on how to do it and especially when there is for instance invoice number and OCR number then pick OCR. also if I could save it with an underscore between them. Ex: OCRnumber_comapnyname. I really appreciate your support and time!
Man Thank you so much, worked like a charm
Finally the proper tutorial. Thank you for your work! Could you please help to rename it by the 16th line for example? Many thanks anyway!
I've managed it (i think) with this code: new_file_name = text.splitlines()[15] rename(pdf, new_file_name + '.pdf')
@@robertcenusa8636 Glad you got it working! Yeah I think that should work, just keep in mind splitlines() will split on the following characters, not just newline characters: www.programiz.com/python-programming/methods/string/splitlines (probably be rare you encounter any of the other characters though).
Moving away from pdfs, are you familiar with API’s ? Can you use Python to code data entry automation to get data from an excel sheet and input it into another program and have it click through a certain sequence of buttons/prompts?
I have experience with APIs although this might be a bit more complicated, I did read something this morning that did sound promising though. Do you have a specific application in mind?
@@stephencodes Chrome, for a financial website. Getting a number from a cell in excel, clicking some buttons in the website then inputting the number in a field, then clicking some more buttons, then going to the next row in excel. OR how about automating going to various sites to download the most recent pdf from a list? I can go on and on, idk if you really wanna read a whole wishlist lol
@@TacosYBurritos8P I actually made a Python script that did this for a IP hosting website (minus the excel part). The script worked for about a year before the website introuduced a captcha system at login I'll try and take a look again, I was reading and there appears to be a way to get past the captcha system maybe. It might take a bit longer to figure out though
Just an update, I'm still trying to make this video... sorry it is taking so long, work and life has been busy
Video is now up with code... Sorry again for these long delays between requests. I hope the video isn't too confusing, if it is I can try to re-create the steps I took in brand-new project.
Reminder: BACKUP YOUR FILES BEFORE PROCEEDING.
Hi sir. Great work, many thanks. How can I change the paper size of multiple pdf files without change there names with for loop? thank you too much.
Hi Mohamed, you can just call me Stephen, I think this should be doable. You're talking about the print size right? Like A1, A2, A3... paper size?
Hey really loved your video and im currently trying to do the same problem.My problem is that i have excel file of names and numbers and have to rename my file using that data.If you could make a video on it it would be great.
Yeah that would definitely be possible! Are you able to provide some dummy lines from the excel file and dummy PDFs/names of the PDFs you're trying to rename so I have a clearer picture? By dummy I mean generic data so you you aren't revealing your actual data
@@stephencodes ok i have a data of 2000+ pdfs and i have to break them into single page pdfs and rename them differently using excel sheet data. the pdf name should be in particular order like 2022_(ID)_(name).you could take any name and numbers to show the example.just help me how with a feasible solution where i have to do it 2000 times.
@@shubhamchavan9287 Okay, that makes more sense now, I'll try working on something
New video is up, let me know if it addressed your problem.
Omg the first time my comment is in a video! Thank you so much for this amazing tutorial! When are you going to set up a Patreon?! Or I can pay you back in calculus videos or any higher level math tutoring!
Haha, first time for everything! I probably won't setup a Patreon unless I manage to do this a bit more seriously. Fortunately, I've already passed calculus 1 & 2 (somehow, haha). Feel free to make another request, I do enjoy making these videos!
IMPORTANT: If you do NOT CARE about what comes after the keyword for the positive lookbehind expression, use the following instead: (?<=Order #: ).+
Hi stephen, how do I make this, but the line after? I´m a litle bit confused... Thanks
@@stefaniamarques9979 Hi Stefania, if we were trying to capture the "Purchase method" line we would uise this regex (I've also included a link at the end of this comment): Order #:.*[ ](.+) Keep in mind we would have to change our code on line 21 (see github) to include .group(1) instead of just .group() (if I did this correctly, I did test it a bit). Refer to this link which explains it better: stackoverflow.com/questions/65503992/how-to-extract-the-next-line-after-a-specific-keyword-when-there-are-words-in-be
How would you rename the pdf after scanning for specific words or format? For example renaming the pdf whatever is in the pdf after the the term “invoice#” or “due” to rename it the due date. Or having a list of names to searching within the pdf and if a particular name is found in the pdf the pdf is renamed that.
New video covers this (just uploaded, sorry for delay)
can you give some examples how to grab, locate or isolate the text to rename the pdf file name from different sections or under particular conditions of the pdf file? The regular expression method you mentioned in the github seems pretty useful for this.
Yes, I'll try and make a video doing some examples of regular expressions. It might take a week or so since I have to bursh up on it.
Sorry, I haven't forgotten about this request. I've just been really busy with school and job searching for the summer. During reading week (this week) I will try and do a video.
Again, sorry for the delay but the new video + code is up.
@@stephencodes bro is the most responsible youtuber I've ever seem. Also, thank you a lot for making these videos!
Thank you very much!
Wonderful, thank you very much!
GIthub: github.com/steve-codes/python-fileRename
Thank you very much, I'd like to rename a set of PDF files based on the title inside the file, how can I do that using python? Thanxs in advance.
This should be possible. I'm currently finishing up my exams but I'll take a look soon.
New video on how to do this is posted. Sorry for the delay! (It might need some time for HD to complete).