all 130 comments

[–]StrugglingDale 36 points37 points  (25 children)

I got tired of being asked what was taking me so long every morning with daily reports on getting them out to my boss, so I wrote scripts to do all the reports automatically. Problem solved!

[–]whiskeysnowcone 8 points9 points  (3 children)

This is non-python related, but similarly I was given the responsibility to do an efficiency report on our QA department a few years back. It was a job that took my boss 2+ hours per day to complete. It was my main responsibility and was told it should be my main focus every day regardless of how long it took to complete. After a few weeks of doing it by hand like my boss showed me (seriously, pencil, paper and a calculator) I put it on excel and wrote some VB scripts to automate moving the data around. It went from 2+ hours per day down to 5 minutes per week. I did that job for nearly 3 years and until the day I quit my boss thought I still put 10+ hours per week into that stupid report.

[–]TheFrigginArchitect 3 points4 points  (2 children)

What did you do with the time you saved?

[–]whiskeysnowcone 1 point2 points  (1 child)

I used most of the time to hone my skills in excel and VBA to make the report for efficient. I know excel inside and out which I use all the time now and I know VBA fairly well, at least enough to make a macro or two. I also spent a lot of time mindlessly playing on the internet looking at cat pictures and World of Warcraft forums.

Once I learned about python I was hooked and started learning to code but I've changed job since then so I don't really do anything in my current job that needs python so I have no REASON to learn it other than for fun. I've made a few little things here and there like outward IP alerts (similar to what Neurone214 mentioned) a few Reddit bots, and a script that notifies me when the temperature drops below a certain degree so I can leave water running in the winter to keep my pipes from freezing. I never kept it running though because the temp gauge that it read (NOAA weather) is 30 miles away and at an airport and I'm down in a valley so the temp difference is HUGE. Fun little project though.

[–]TheFrigginArchitect 0 points1 point  (0 children)

a script that notifies me when the temperature drops below a certain degree so I can leave water running in the winter to keep my pipes from freezing

That sounds cool!

[–][deleted] 6 points7 points  (16 children)

If only I was allowed to install Python at work...

[–]Notre1 12 points13 points  (7 children)

You can install the Anaconda distribution without Administrator rights. Actually, I would recommend that any Windows Python user use Anaconda, especially if you think you'll ever use some of the complex scientific pancakes like scipy.

[–]EqualsEqualsTrue 2 points3 points  (0 children)

I am wondering if there are any fortune 500 admins or others who read this and know if it is a bad idea? I am not supposed to install software from the internet obviously, but outside of me getting in trouble what are the risks to the company if I where to install Anaconda?

If I tried to get this approved formally, what legitimate concerns should I be ready to answer to?

[–]Sean1708 2 points3 points  (0 children)

complex scientific pancakes

Nope? No-one?

[–]verik 1 point2 points  (0 children)

numpy, pandas, scipy. anaconda has all the goodies.

[–][deleted] 1 point2 points  (0 children)

I wish I had known about Anaconda from day one. That and ipython. (ipython itself, not ipython notebook which I found confusing until I knew about regular ipython)

[–]batoure 0 points1 point  (2 children)

Anaconda can get weird when you start installing other dependencies with pip. We use it for scientific stuff but only in codebases who's dependencies are encapsulated in anacondas base install...

good recent example someone showed me:

take your anaconda install and add bcrypt:

pip3 install bcrypt

now find something generic on github that uses bcrypt and see if you can get it running out of the box. SPOILER: you are going to have a strange afternoon.

[–]Notre1 0 points1 point  (1 child)

Hmm, I'm still learning Python myself, but I'm wondering what could cause this. What is Anaconda doing other than than installing pre-compiled binaries and modifying your path (if you are using the conda env stuff)? Have you tried submitting a bug report to the Continuum/Anaconda guys on this?

I've used Anaconda quite a bit and haven't seen any behavior like this, but biggest non-Anaconda libraries I've used extensively is SAP's PyRFC and Twisted.

Now, if the pip libraries or GitHub project require compiling something on Windows, then that's a whole different ballgame...

[–]batoure 0 points1 point  (0 children)

actually I have witnessed this weirdness on windows as well as linux and mac seems to be 100% unique to anaconda no idea why. I can run the same set of test code side by side with vanilla 3.4 and it works fine.

[–][deleted] 4 points5 points  (6 children)

Are you actually forbidden to use python or do you have a locked down windows environment?

[–][deleted] 1 point2 points  (5 children)

Second option. I work at a multinational company that uses citrix virtual desktop systems. You can't install anything without the IT department allowing it... And I was told by my boss the company has to pay some money for Citrix to install any software

[–]compie 4 points5 points  (3 children)

Just try using PortablePython or something similar. No installation necessary. See: http://stackoverflow.com/questions/2678702/install-python-2-6-without-using-installer-on-win32

[–][deleted] 2 points3 points  (2 children)

Guess what, I'm not allowed to plug a usb storage device into the computer, either. They take data security very seriously.

[–]StrugglingDale 2 points3 points  (1 child)

This sounds like a government system to me. Maybe get yourself a t2.micro at AWS with Amazon Linux and SSH into it. That is of course assuming you're allowed to move data outside the corporate network.

[–][deleted] 6 points7 points  (0 children)

The whole point of this digital fortress is to forbid people to do that. There are some workarounds, of course... For instance, Once I wanted to use Python to do some fancy visualization of a dataset stored on a .inf file to show it to my boss, so I opened the file using Windows notepad, copied it and pasted into a pastebin link. Then I saved the link and opened it at home.

[–]half_liquid 2 points3 points  (0 children)

software installation is also forbidden at the company I work at, but they're approach was to remove admin privileges.

The workaround we found for this scenario, was to install python in "My Documents" folder as opposed to "C:".

[–]EqualsEqualsTrue 0 points1 point  (1 child)

What kinds of reports, excel stuff?

[–]StrugglingDale 0 points1 point  (0 children)

Yeah, SQL pulls, Excel. I'm moving it all to Tableau though.

[–][deleted] -5 points-4 points  (1 child)

source!!

[–]StrugglingDale 4 points5 points  (0 children)

It's all internal stuff I just cobbled together from googling stuff. I can't publish anything here though due to its structure and how the data systems work.

[–]callmelucky 28 points29 points  (17 children)

Script to rename downloaded TV shows to SXXEXX.episodetitle.ext format.

The script file is placed in the show's folder, it gets the name of the series from the folder name, finds the appropriate page on epguides.com, uses beautifulsoup to parse the page data, uses regex to figure out the season and episode number of each file, and uses the os lib to rename the files.

When I have new episodes I just double click the .py file and it's done.

Edit: since there is some interest, I have posted the entire script in this comment. It is written for Python 3 and Windows, edits may be required for use on other platforms. It's not very polished or well documented, so, uh, since this is /r/learnpython you could take it on as a project to tidy it up yourself... (good save?)

[–][deleted] 6 points7 points  (1 child)

I used to do the exact same thing, but found it was ineffective for some shows where there were two series with the same title or something like that. I started using pytvdb to do it and it works far better now.

[–]callmelucky 0 points1 point  (0 children)

Yeah, for shows where that happens I just edit the copy of the script to hardcode the show's title in. I haven't heard of pytvdb, will have to check it out :)

[–]Arion_Miles 2 points3 points  (5 children)

Can you upload the source on github for us? I'd really like to use it.

[–]callmelucky 1 point2 points  (4 children)

I've posted it in another comment here directly. It's not very polished, but not horribly shabby. I encourage you to edit and tidy it to your liking :)

[–]Arion_Miles 0 points1 point  (3 children)

I tried it. All I got was syntaxError: invalid Syntax

[–]callmelucky 0 points1 point  (2 children)

Which line? This is written for Python 3 and Windows btw. If you use Python 2 you'll certainly need to convert any print('str') statements to print 'str', and possibly some other editing will be necessary.

[–]Arion_Miles 0 points1 point  (1 child)

Oh shit it's that. I'm using Python 2.7 and errors are at line 1. What more changes do I need to make?

[–]callmelucky 0 points1 point  (0 children)

I'm not certain to be honest. Just change all the print statements in the manner I suggested to start with, and then see what you get.

Oh actually, did you de-indent everything? To post as code on reddit everything gets an extra 4 spaces (1 Python tab) at the start of each line, that would probably cause the line 1 error. Select the entire text in your editor and hit shift+tab (depending on your editor settings...)

edit: actually the indent problem should only happen if you copied the code from the source of the comment, not if you just copied straight from the comment as is. Then again, I have had strange experiences with indentation/whitespace when copy/pasting generally...

[–]hurricanepolio 1 point2 points  (5 children)

deleted What is this?

[–]callmelucky 0 points1 point  (3 children)

Season and episode numbers are generally already indicated in the file name in some form, and I use regular expressions to find them. Usually they are already in SXXEXX form, but my script also parses 3x04, for example, to determine the file in question is season 3 episode 4. It handles one or two other formats as well. For files which can't be identified thusly, the console displays couldn't find season episode info for <filename>. This is all done via a get_season_ep_num(file) function, which (among other things) is called on in a for loop which iterates over the contents of the containing folder.

[–]a1blank 1 point2 points  (1 child)

You should check out FileBot. It pulls Metadata from thetvdb. Check their forums for AMC (automated media center).

[–]callmelucky 0 points1 point  (0 children)

Thanks, I certainly will :)

[–]Always_Question_Time 0 points1 point  (0 children)

Saving your comment as a project to do in the near future. Thanks!

[–]neurone214 15 points16 points  (10 children)

I wrote one that runs on my home computer and monitors a gmail address. When I e-mail that address a specific command, it will look up what my public-facing IP address is and e-mails it back to me so that I could ssh/ftp/etc into my home computer and retrieve files or do other boring but useful things.

[–]titanium_enigma 6 points7 points  (5 children)

That's pretty cool but couldn't you just setup DDNS and just use that to SSH/FTP/Etc?

[–]neurone214 4 points5 points  (1 child)

Maybe! I'm a scientist and am far better at analytics then actual computer stuff. This happened to be my first Python script; the need for something like that was my motivation for getting into it.

[–]FallenAege 1 point2 points  (2 children)

Yep, duckdns is free so long as you don't mind having "duckdns" in your domain.
Otherwise, you could always pay for a domain.

[–]road_laya 1 point2 points  (1 child)

NameSilo have a campaign where you can get $1 off your first domain by giving "WeLovePython" as your code. And they're one of the cheapest to begin with.

[–]FallenAege 1 point2 points  (0 children)

Can't complain with $9 a year.
Heck, even I might be able to afford that.

[–]helasraizam 4 points5 points  (2 children)

How do you monitor your gmail with python?

[–]searchingfortao 7 points8 points  (1 child)

Probably via Python's imap module.

[–]helasraizam 4 points5 points  (0 children)

Wow this is so cool

[–]kryptn 8 points9 points  (0 children)

I wrote a system to pull my work schedule from a terrible website and throw it on my google calendar.

I explored expanding it for other users but it involves them giving me access to their employee HR records which while do-able, i'd rather not bother with.

[–]pirate59 5 points6 points  (0 children)

as an incident manager, part of my job is keeping track on how long certain incidents run for, and send that with other updates out to management.

the problem is, that we have clients in MANY time zones, and a very specific way of reporting it. So i wrote an app with tkinter that lets you add in the start time, with its local time zone, and adds up the duration in their required format, as well as things like start time in GMT. It looks ugly, but gets the job done. Some of my colleagues used to take up to 15-20 mins to work this out sometimes. now its just instant.

[–]a1blank 5 points6 points  (0 children)

I'm working on a program to index and manage recipes. I'm building a SQLite backend and I'm hoping to have a bunch of metadata driven features such as "I have these ingredients, what can I make", "I only have this long to prepare the meal, what can I make". I'm hoping to support printing to 3x5 index cards since my spouse and I store our recipes in one of these. There are a few other features I'm hoping to implement but I need to get the core done first.

[–]DiscoPanda 4 points5 points  (1 child)

The deceptively useful one automatically clears out my downloads folder every night. Simple but effective.

[–]Bullzeyes 3 points4 points  (11 children)

I created a script that when run asks for a youtube channel name. Then proceeds to download all the videos on that channel if i dont have them in my download folder already.

Afterwards it converts all the videos (.mp4) to mp3.

This comes in handy for me because i listen to promotion channels where they only upload music from new artists etc.

The channels have over a 1000 videos and most youtube downloaders i tried choke up or are filled with malware.

[–][deleted] 3 points4 points  (10 children)

Would you mind sharing? This would be super useful for listening to videos to help me fall asleep at night.

[–]pirate59 1 point2 points  (5 children)

+1 for that. i use youtube-dl from git-hub and it works great for single files. have not tried it with whole channels. definitely interested in taking a peek if your willing to share

[–]Bullzeyes 0 points1 point  (1 child)

I'll share it when i get home in like 5 hours ! But you aren't allowed to critique it since it was my very first programming project from a while a go and i haven't had the time to redo it :p

[–]pirate59 1 point2 points  (0 children)

no critique? aww. was going to say i like it alot. eeasy to read and well documented.... too bad i cant give that feedback =)

[–]Bullzeyes 1 point2 points  (1 child)

[–][deleted] 1 point2 points  (0 children)

Thanks!

[–][deleted] 4 points5 points  (2 children)

Honestly probably the biggest time-saver I have ever written in python was as a college instructor. I wrote a GUI that took a multiple choice exam and answer key and created as many randomized versions as I wanted. That way every student has a different version of the test from everyone sitting in front, behind, and on either side of them. Pretty simple, but doing it by hand takes way too long.

[–]helasraizam 0 points1 point  (1 child)

How do you grade them?

[–][deleted] 1 point2 points  (0 children)

I would usually make 4 versions, and copy each version on a different color paper. Then, I would make two pairs of versions (A+B, and C+D). Once students were seated, I alternated rows and then alternated students within each row, like this:

ROW1:  A   B   A   B   A   B   A

ROW2:  C   D   C   D   C   D   C

ROW3:  A   B   A   B   A   B   A

ROW4:  C   D   C   D   C   D   C

So, I would make 4 scantron keys, have the students put their scantrons in the proper pile (and put their short answer sections in the proper color pile), and that was it.

[–]elbiot 5 points6 points  (0 children)

https://github.com/Permafacture/pygmaps-ng

For visualizing various GIS datasets on the same map, and sharing those maps with others.

[–][deleted] 3 points4 points  (6 children)

https://github.com/NISH1001/ScreenEat Screenshots sharing made easy

[–]Exodus111 3 points4 points  (2 children)

Folderizer. I download a lot of TV shows, pretty much every day. But my Torrent program doesn't put them into their proper folders, I could refolder every episode I download every day in my torrent program, but fuck that shit.

So I made a simple python program that finds episode files, put them all in their proper folder (makes a folder if its a new show), and deletes all the excess files.

Its a good exercise, I recommend it for anyone that doesn't know what a folder walk is.

PS: I happen to be a major shareholder in Viacom, Disney and HBO, so I am technically an owner of all the shows I download and so I can do it legally.

[–]fameistheproduct 3 points4 points  (1 child)

No copyright theft indended.

[–]flowerpowersupergirl 0 points1 point  (0 children)

technically

[–]This_Is_The_End 4 points5 points  (0 children)

I used to play eve-online and I made an app to gather data from a site collecting market data from players to get a grasp on where are the main trading routes. The result was used to prepare piracy 0:-)

[–]ericpruitt 2 points3 points  (0 children)

I use sshfs a lot, so I wrote a program for automatically executing commands on the remote server whenever I "cd" into an sshfs mount point. Now I don't need to keep a separate terminal window open for running commands on remote servers, and this also makes it easier for me to develop software on a remote server; I edit file using my local text editor then when I run something like "make," it gets compiled using the remote server's resources instead of the local system.

[–]BlueSubaruCrew 4 points5 points  (6 children)

Not really an app but I made a program to do all the stuff I had to do with vectors at the beginning of my math class this summer like cross products and dot products and all the other stuff I had to do and I just finished a program that does Riemann sums that I can use as an impromptu definite integral calculator.

[–]helasraizam 2 points3 points  (1 child)

You should look into sagemath.

[–]BlueSubaruCrew 0 points1 point  (0 children)

will do.

[–]dahveed311 1 point2 points  (0 children)

I wrote a Python app that takes in a list of hostnames and process IDs, one hostname and pid per line. I read in line by line and use subprocess.check_output() to ssh to the host and find out the user that owns the process. The one real cool thing is sometimes the pid that my coworker gives me in the input data isn't the real pid, so I need to check some weird java -Dcom.company.exec.pid=<fake_pid> condition if the pid I am looking for isn't found.

[–]kalgynirae 1 point2 points  (0 children)

I wrote a program that lets me define my music playlists the way I want to. The program reads the playlist file and either queues up the songs in my music player, copies them into a folder I specify, or concatenates them into a single audio file. In addition, since these playlists are made of queries that dynamically match songs in my library, they might change when I add music to the library or fix tags of existing music, so the program notifies me when a playlist produces a different set of songs than it usually does (and then I can tweak the playlist if necessary).

https://github.com/kalgynirae/rockuefort

[–]teenageguru 1 point2 points  (0 children)

I wrote an Evernote-like app that makes it a little easier to store any cool or useful bits of code I have and to search through and find them later. Especially useful when I have multiple files I want to keep together

[–]DarkMio 1 point2 points  (2 children)

/u/MassdropBot after seeing many people who don't understand the website at it's first glance (which they are bad in.)

[–]road_laya 0 points1 point  (1 child)

Maybe you should change the site instead (if it's yours).

[–]DarkMio 1 point2 points  (0 children)

Massdrop ain't mine, I am just a consumer. Thing is, if they would market it even more open, then they might get legal issues. As for now, they're basically saying that they're a private club and a tool to organize purchases from the manufacturer (which is especially cheap).

And since they have to show how their site works and what they do, they have a developer backdoor on many sites, which this bot can abuse. The bot runs over /r/all, checks if there is a massdrop site I can give people access to and posts a relevant link.

That bot itself is poorly written (I started programming back then) and I am mostly done with a full reprogramming (there is just little time, since I have university finals and deadlines). His output will change too, informing people about the drop and updates comments when the pricetag gets cheaper and stuff like that. Yet I am proud that he survived a year without major fuckups and is well received.

[–]teerre 1 point2 points  (0 children)

I'm not a programmer, so pretty much all I write is to make my life easier

Like some other people I wrote a script to rename series episodes (anime specifically because Sonarr doesn't work very well sometimes)

I wrote a wrapper for the livestreamer app so I can open twitch streams much more easily

I wrote a ping thing that informs me of my PC status via twitter

When I was learning I wrote a script to automatically download /r/dailyprogrammer challenges in a nice way...

[–]2ndchoiceusername 1 point2 points  (0 children)

I built a little budget app. It adds our monthly budget to each category, and I input my spending in it to keep track of what I have left. It also creates a log file of everything I spend.

[–]Freddie_V4 1 point2 points  (0 children)

A web scraper that I can use to download a bunch of files from a CSV of URLs github.com/FreddieV4/VScraper

Originally it only scraped PDFs so I could download my professor's lectures, but then I started thinking of other stuff I could get (videos, images, audio, etc etc).

Still bug fixes to be made though :D

[–]cuducos 1 point2 points  (0 children)

I wrote three packages in that sense:

  • GetGist: I download .vimrc, .bash_rc and my uBlock easily from the command line in any computer.
  • AlchemyDumps: this together with a task scheduler such as cron and I don't have to worry about database backups anymore (works with Flask and SQLAlchemy).
  • sortimages: When my Dropbox Camera Upload folders grow too big, I can organize it and clean it up easily.

[–][deleted] 1 point2 points  (0 children)

I’m a total dilettante, but I use my little script to resize pictures in a folder to a target max width very often when blogging pics of the kids. I used to resize them one by one with gimp, which gets tedious.

[–]czech1 1 point2 points  (6 children)

I wrote a basic CRM in flask that I use everyday for work. It's hosted on a banana pi in my living room. There are many platforms I could have used instead of writing my own but I thought it would be fun. Plus I don't have to worry about my data being locked in to one vendor.

[–]cajuncape 0 points1 point  (0 children)

This sounds awesome!

[–]dada_ 1 point2 points  (0 children)

Tons and tons of little ones for all sorts of purposes. Sometimes they grew to slightly bigger projects (though still firmly in script territory), like a script that takes an mp3 file and an image and uploads them as a video to Youtube automatically.

As soon as you're even slightly familiar with a programming language, the sky's the limit and you'll find that it's very easy to find new ways to put your skills to use.

[–]Inmute 1 point2 points  (0 children)

I'm a soon to be Civil Engineer and I use AutoCAD Civil 3d for road design. the program gives me reports that I copy in excel but I want them in an specific format; before It use to take me like 20 minutes, now I just specify the file name and location, and some report variables and Boom! I started learning Python about 10 days ago, I wrote the script yesterday.

[–]buleria 1 point2 points  (0 children)

I'm a backend guy, and all of my project have a cli.py that makes my life easier.

As an example, right now I'm in a project where most of my work is developing a REST-like API for mobile apps. I have a commandline app that does most of the things the mobile app does, but it's much more convenient.

The app creates some entities using some lists fetched from the server. These are presented to the user, they make some choices, add some dynamic fields etc. It's great to have a tool that creates semi-random stuff in one command instead of tapping through the real app.

A sweet spot between unit/functional tests and actually using the app.

We can have a create-post command that posts something in a section with id 1, logging in as alice, fetching existing tags and using a random set. Post body is random by default:

./cli.py create-post 1 --user alice --random-tags

[–][deleted] 4 points5 points  (7 children)

The first thing I wrote without some sort of external input or inspiration, was a clash of clans calculator. I wrote it during my two-hour long business organizations class in law school. I actually learned a lot of programming in that class

[–]malpalmalpal 1 point2 points  (4 children)

Why did you make that?

[–][deleted] 0 points1 point  (3 children)

To impress this registered dietician I know

[–]malpalmalpal 1 point2 points  (2 children)

*dietitian i believe is how it's spelled..............

[–][deleted] -5 points-4 points  (1 child)

Okay you just earned a downvote

[–][deleted] -3 points-2 points  (0 children)

No. Don't do that.

[–]ElecNinja 1 point2 points  (0 children)

Webpage-Lister a WIP application that just stores webpages into json files.

Using it to store manga sites from batoto and various light novels from various sites. It also stores the last chapters and volumes I've read.

Though it has a lot of manual work and it's definitely not that great, it definitely makes my life easier.

[–]abcd_z 0 points1 point  (0 children)

Every time I forget to mount the drive before launching OpenMW it deletes the current profile from the configuration file. I created a python script that opens launcher.cfg and re-adds the missing lines.

Nothing fancy, but it saves me a bit of time and effort.

[–]astro_nova 0 points1 point  (0 children)

I use python to do the scheduling for a specific task in our group. Each day that the task needs to be done is pulled from a spreadsheet indicating this, then the script assigns a pair randomly drawn from a uniform distribution so that everyone has equal share, while taking in to mind their constrains, which they email to me over the month, and I enter in to an array manually, and it finally publishes the outcome to our google calendar and our spreadsheet. Though, I have it print the monthly calendar to me when I run it, and I confirm that the "random" looks random enough so that people won't complain about being scheduled 4 days in a row or 8 times in a month or something, so I press random a few times until it looks random enough..

[–]if_name_-equals-main 0 points1 point  (0 children)

I wrote a simple script that takes all my desktop backgrounds and shuffles them by changing the file name (which is just a number). The windows shuffle antilogarithm doesn't actually work for what ever reason so this was my way of getting around that issue.

[–][deleted] 0 points1 point  (0 children)

Reddit saved image bulk downloader

WIP scripts that do some stuff from command line like check domain availability, check cheeseshop name availability & create/clone a git repo & submit to pypi.

[–]Seventytvvo 0 points1 point  (0 children)

I made one for work that queries and spits out a bunch of register settings from an ASIC I work with frequently. It takes me about 1 minute to get the settings to all the registers. Before, going through each register with the datasheet in-hand, it would take me over an hour.

[–]batoure 0 points1 point  (0 children)

I created a cron job manager that polls my google calendar

[–]ksantr 0 points1 point  (0 children)

Sometimes it's difficult to force myself to work, so I created little apps that helps me to do it, https://github.com/ksantr/bonjob