PRO TIP…. NEVER, AND I MEAN NEVER… turn in work right away when you finish early. Your PM is just gonna give you a crazy amount of work and tell you to finish it by EOD! Screw that. Use your last 2 hours to study or relax or play video games. Sincerely - software developer, 11 yrs
If he got the files from his boss, it's probably downloaded from an email or something, so he can just re-download them if something goes wrong. If he has the only copy, though, then yeah he should have made a backup first lol.
Side tip .. your boss (if corporate America) would probably not give you a raise for this, they'd just drop more Python work on you without compensation. If you were not hired as a programmer, you're better off doing it, then going to the bathroom and playing candy crush (or whatever) for the remainder of the time it'd take for someone to do this manually. 😀
Unless that playing candy crush isn't gonna get you anywhere, and probably nothing will, so you'd better carefully choose who you work for and know if they're worth you
Or... spend that extra time further developing your skills, then apply for a job that needs them and get a higher salary. Don't waste your time when you're capable of so much more
I learned python as a grad student. When I started my first job as a researcher, the team had a task that the boss allocated 6 hours / wk for which was basically running the same program on a directory to generate data, then sending that directory off to the software engineering group to process. The people before me had no Linux or programming experience. I automated this process and humans didn’t touch it anymore. My boss didn’t give me a raise, he gave me more python work 😂. But I loved it and it eventually allowed me to transition into software engineering full time.
I`m experiencing this with VBA. Only difference is i haven't made the rookie error of informing my managers hoq hyper efficient ive become im using the spare time to learn python, JS and CSS - perhaps some HTMl down the line so I can hopefully transition to a sev job in 14-18 months
@@Dan_Therapist that’s about how long it was for me - 16 months. I definitely made that rookie mistake the first time. Future tasks I always gave myself a bit more buffer to bake some learning into my work day, haha. The fun part about having a non-technical manager is that he had no idea how long coding assignments did or should take.
Fun fact, using YYYY-MM-DD removes confusing ambiguity between parts of the world that use MM-DD or DD-MM and means when you order alphabetically they are also in date order
@@tauon_I suppose one argument would be that standards tend to erase needed diversity. Be it culturally (dialects and regional languages are dying all around the world, and I don't think India would be okay with british people coming to their country a second time and telling them to stop using the Panchanga calendar for the sake of standardization), or even locally (the ISO standard cup of tea absolutely sucks and is not to my taste at all). Sometimes switching to a standard is not worth it (Switching the American grids to 50Hz would cost trillions, if not more, and there would be very little benefit to doing that), and, to quote The Office, "the flowers arrange themselves". Standards are a necessary part of global trade, but deviations from the standard are also extremely important. Not everything has to be standardized.
And when using pathlib glob, the objects you get when iterating over its output will be Path objects already, so no need to wrap them to get the rename method.
Pro tip: use YYYY-MM-DD format on filenames for automatic arrangement in chronological order. Edit: clearer example: DD-MM-YYYY shuffles up date order.. because dates get ordered by DD first, then by MM and then YYYY. Eg. 01-08-2022 02-09-2019 03-05-1999 03-07-1980 05-01-2021 Whereas YYYY-MM-DD produces a clean chronological order (asc or desc) 1980-07-03 1999-05-03 2019-09-02 2021-01-05 2022-08-01
@@nagarajansubramani wherever you use those dates, you can sort both ways. What part to elaborate? You can sort in Windows explorer, in Python, in Javascript.
@@robmulla The only reason to feel strongly is if they're used to one format as standard. As far as computer systems go, YYYYMMDD should be the way to go, because mathematically it results in chronological order due to accurate numerical representation. 2020-01-03 is 20,200,103 to a system, which naturally before 2022-08-02 (i.e. lesser than 20,220,802).
And this is why software engineers earn so much despite not always actually working full days : they take a process that took someone else a good portion of their time every week and automate it in a few hours so that no even ever touches it again
I mean this is pathetically easy, and a literal monkey could do this. Why would a software engineer deserve to get paid heaps for this when a HR person could Google it, copy code from stack overflow and have it work. Let's not kid ourselves, most SWEs are overpaid. It's not that hard.
What are you even talking about? 30+ yrs as a software dev ... min 55 hrs a week and on call 24/7/365 even when on vacation. Get paid for working less just ... wut?
@@jasonroos5781 few people treat developers as human and attribute their engineering feats as the computer's work. this is why everyone should know how to code or at least how codes works. then they will appreciate the work of developers. just like how people know how to connect wires but still pays electrician for their superior work.
Actually more or less how I started with Python. I am an apprentice for a completely different field, but got fed up with a lot of inconsistencies in our workflow, so I started doing a lot of "magic" with Excel. Getting fed up with its many issues and limitations, I did switch over to python after a bit, and not even one year later, here I am as our local data engineer still learning on the job by myself
I’m not quite at the level of fully understanding everything you did here (mainly the library imports and the specific functions/method used from them) just yet, but I was able to see what you did overall - really cool! This inspires me to keep learning so that I can get there. Thanks for posting 😊
it’s okay, while it can be useful to know what certain libraries do, no one expects you to learn a programming language by just memorizing functions, you learn them as you go when the need for them arises
Now, I’d normally say that if your boss addresses you as "Subordinate" and refers to themselves as "Boss" that it’s going to be a toxic work environment, but if I got a raise every time I saved the company time, I’d let them call me "Subordinate" all they wanted. 😂
Nice solution! Here's what I would've done in that situation: I had no idea glob existed, so I would've just used os.listdir and used the for loop on that. I would have used the datetime module for making the date time the default. I haven't used pathlib much so I'd have used os.rename instead (I find it more readable than a bunch of Path objects)
Since this is a simple utility script, it's fine. But when working on a bigger product, you should try to avoid import bigger libraries like Pandas just to use their utility functions. It affects both memory usage and the startup time. Instead, you could either use your own logic (like using regular expressions for example) or check the library's source code to see how that particular function is implemented and you tailor it into your own code.
Be cautious with `filename.rstrip('.txt')`! This method treats '.txt' as a set of characters to remove (t, x, .), not as a sequence. So, 'latest.txt'.rstrip('.txt') unexpectedly becomes 'lates', not just removing '.txt'. A safer approach: `filename = filename[:-4] if filename.endswith('.txt') else filename`.
came to say this. if you want them sorted numerically, sort them in descending order of significance. Year > Month > Day. (and always used the ones padded with zeroes) just like: Thousands > Hundreds > Tens > Ones
I would test it first with print statements and the renaming commented out. Don't want to accidentally completely mess up the filenames that you loose the information you need from them.
Never ever tell them you finish early. They'll just put more work for you without giving a raise. Send it to them after a period of time. If they are tracking your work, then make a program to trick the tracker. Man, work life is hard.
i was so ready for an ad or some other tacky bs, but partly cause im interested in coding, and partly the funny af comments, this is pretty unique, keep doing you man
Tbh you could have chat GPT write the same thing for you by describing the problem, some python would definitely speed it up though to get a sample of the file names listed in plain text.
This is basically how I learned programming. But instead of turning in the work and getting more work in return, I did more online courses on programming.
God I remember this GUI. Used to ride and die with ubuntu/mint for years. Good times were had then. Now Im honestly just too busy for an ultra flexible os. Bought a macbook when i got my first real job, and it serves all my purposes. Still nostalgic looking back, legit good times.
Using python to solve problems like these is super fun, I do it all the time, honestly it always takes me longer to write the code than to do the thing manually but i don´t care since it´s more fun. As a famous tweet once said : "Never spend 6 minutes doing something manually when you can spend 6 hours trying to automate it"
@@robmulla This is what i am doing. But quiet often these ppl are trying to steal my codes and then they see the "demonic" stuff i have commited. Normally i get then insulted for beeing a bad programmer. 🙂 I hate these guys so much .....
Nah bro, do it, don’t turn it in until the last minute. Procrastinate the rest of your day and if the manager drops by just open a report and “check” everything is in order
There is a Tom Scott video similar to this. Long story short, when youve been given a menial task, dont underestimate your ability to fuck it up by trying to be extra productive.
My strat is to get the filenames into excel and use formulas to make another column with the correct filenames. Then I can see before and after and also check for duplicates etc. Then make a column which takes the old and new filenames, wraps both in quotes and adds "ren " before both. This column copy/paste to notepad and save as doit.bat. Then in a command prompt, I run doti.bat. (I had to rename about 300 Salesforce fields to add a prefix. The tooling I was using used the filename of the field definition file as the object name. If you're familiar with Salesforce, I'll applaud you for figuring out the shortcomings of this method here but I was about a month into SFDC dev at the time so...)
I know this is a short, but before executing code that has an irreversible action if it goes wrong, such as renaming a file, you should execute it without that part with as many tests as you can. If possible you should also not take irreversible actions in the first place or having a some sort of rollback mechanism when possible. Like in this case you could just copy the files with the amended name. That way, if something went wrong, you can fix the code and try again without penalty. I know most of us know this by learning the hard way. I’m just hoping I have caught someone before they had learn like we did 😅
It wasn't my first day or year, and it wasn't my supervisor. But once, a coworker came to me saying " I have a riddle for you." There was an old database from a deprecated programm. The file names were somewhat cryptic, as was the folder structure. He gave the same task to a senior programmer who told him the file names are in HEX. "You know, that's what it was in the old days. The young guys sure don't know that." It took him 15min. to figure out where the files are. It took me 4...
Another tip, even tho i've never done anything like this i suppose you ahould test it out on a different folder you made with like 4 files first so you wont end up with all the files named "NameError" and make it completely unsortable
And by raise I mean we're giving you the standard 3% despite your excellent performance reviews. Happy New Year, also I found some more files that need organizing, please return by EOD.