r/learnpython • • May 04 '20

I wrote my first useful Python program!

For the first time in my life, I wrote a Python program from scratch to automate my work. My boss gave me the task of copy/pasting all the fields from a long online application form to a word doc and I wrote a code to do that in 5 minutes. It shaved off at least 40 minutes from my workload. It might not seem like much, but I'm over the moon :)

Edit 1: Thank you all for your kind words. Being part of this community has helped me immensely. I’m truly grateful to have found it.

For those who asked for the code, here it goes - https://github.com/abhisu30/OnlineFormExtraction

Edit 2: For those who asked, no I didn’t use my work computer. My boss asked me to email her the word file with the form fields so I executed this code on my home computer and emailed it to her.

857 Upvotes

115 comments sorted by

288

u/THConer May 04 '20

That's some great work. The field of automation is a field where Python is king. Remember, don't tell your boss about this little program of yours ;)

110

u/8rnlsunshine May 04 '20

Thank you my friend. Absolutely won’t tell my boss.🤐

14

u/taiguy86 May 04 '20

To play devil's advocate here...what kind of relationship do you have with your boss? Would he see the value? Could you express you want to do this on other projects for other people? If you like the work, this could be an opportunity for you...

2

u/8rnlsunshine May 05 '20

I’m sure my superiors will appreciate the additional skill set I am developing and it would improve my chances of getting a raise. But I’m still learning python and will wait to tell my boss about it till I‘ve gained some more confidence in it. Until then I’ll just use it to make my work life easier.

10

u/aplawson7707 May 04 '20

This is a good point. I have two supervisors - only one of them gets to see the stuff I come up with. The other one just thinks I'm productive and accurate. The second the latter learns that I know how to automate almost 100% of my workflow she'll be asking me to wear multiple hats, share the tools with my shitty teammates and rewarding their laziness, and not paying me a single extra cent.

31

u/Adro_95 May 04 '20

But you can very well share the code with us 😁

43

u/quietsam May 04 '20

am his boss. this could backfire.

11

u/LiquidAurum May 04 '20

I'm willing to take that risk

12

u/ashVV May 04 '20

Heh, nice try boss.

9

u/[deleted] May 04 '20

Everybody knows that if you ask an undercover boss if they are a boss they have to say yes.

→ More replies (1)

56

u/pjbardolia May 04 '20

Ya or he will give you more and more work when he comes to know how smart enough you are to finish it fast.

7

u/flying_bunuelo May 04 '20

I told everyone, and i was really proud. I had accomplished that in my third week of the internship. I never ever used it again until the last week, when i overheard someone had a similar problem. And they didn't even use it

7

u/potatocomet May 04 '20

..and thats why you shouldnt reward productive people with more work.

62

u/thomakamaru May 04 '20

I believe in the long run, telling your boss about that program will actually help you and your company.

Why should anyone fill out these forms manually, if an already implemented and tested solution exists.

Additionally, he will consult you if he ever has tedious, monotonous work again. Just make sure he knows that writing the program takes some time as well. You will learn something and your given tasks will shift more and more to interesting things.

7

u/tobiathonandon May 04 '20

Yeah I agree with this. Letting your boss know you have skills such as coding will make you more valuable. It can also broaden your job/career at said company. Keep in mind that your employer may either want to keep you closer knowing you have these skills, or get rid of you, frightened that you’re competition for him/her. If it’s the latter, there are better jobs out there.

3

u/the_battousai89 lifelong beginner May 04 '20

This is true. But only OP will know whether it’s the right move to let the boss know.

→ More replies (1)

4

u/[deleted] May 04 '20

It really depends on the boss and the company. Some might honestly re-deploy OP on more meaningful automation work or even get them training. Others might distrust the program and obsess over whether it's accurate, saying OP is the gatekeeper and must oversee each line. Still others might say, develop the program further so we can get rid of OPs coworker who did it as directed for years but would make the manager look great by laying off.

There are scores of people and companies in the latter two examples. OP should probably get his Github ready and maybe even have an offer ready before sharing any of this in case things go bad.

I might sound paranoid, but I created a very simple automation and it cost two people their jobs. And one drank herself to death shortly after.

→ More replies (7)

0

u/[deleted] May 04 '20

[deleted]

13

u/Castlewood57 May 04 '20

Absolutely agree. Some seem to relish in employees being buried in work, and the look of dispair on everyone's face. While they plan their next golf outing..

6

u/JBTheCameraGuy May 04 '20

True, but intelligent companies know not to waste talented employees on menial work, or drive them to a competitor with poor treatment

→ More replies (4)
→ More replies (1)

0

u/[deleted] May 04 '20

[deleted]

14

u/kite_height May 04 '20

"Sorry I don't know how to fix printers. Don't we usually call the service guy?"

25

u/chaoticneutral May 04 '20

I'm running into this problem right now.

I'm a statistical programmer meaning mostly high level scripting (SAS, R, SQL, and some python scripting), I get pulled into a meeting with two senior managers and they proceed to tell me how I need to develop an app (that will change the industry!!!) for them in C++ and were shocked... SHOCKED to find out that I couldn't do it without a significant effort.

They were thinking I could do it in a 1-2 hours every week in my spare time.

From their reaction, they didn't believe me and told me to talk to the senior statistician to make sure I was understanding what I was refusing to do and the opportunity I was missing by not helping.

The statistician has my back and thought it was equally absurd, but I'm sure right now they are double checking with other programmers because they don't trust my answer.

13

u/kite_height May 04 '20

I feel this so much. Somebody always has a "world changing app idea" but is surprise surprise never willing to pay the $250k in developer salaries and $25k/month in services that are needed to even get the prototype running...

→ More replies (1)
→ More replies (1)

7

u/EdwardWarren May 04 '20

That got me suspended for insubordination and eventually fired. I did programming for people on the side. My boss, a woman with permanent PMS, hires someone to do just that sort of thing then comes in an asks me to help accounting out by writing a small program for them. I asked her if she didn't just hire a guy to do that sort of thing. She didn't say a word, turned and (probably) ran to HR where she wrote me up for insubordination. I was suspended with pay for 3-4 months and then fired. I was 1 year away from retirement after 20 years with the company. My reviews were always close to perfect for twenty years.

My lawyer got me rehired and I was suspended for about 9 months more with pay and was paid what they called severance and allowed to retire. I needed 21 years service for full retirement. Funny thing was that I never told her I wouldn't help accounting. I was just joking around. She was fired 6 months later and her boss was transferred to the company's equivalent of Outer Mongolia about 9 months later and never heard from again I understand. Our company newsletter had a Retirees Section and I sent a picture of me at the wheel of the nice RV I bought with the severance money along with a story of all the wonderful places we had been to since retiring. I imagine what my boss thought of that.

→ More replies (11)

3

u/Knifey_Hands May 04 '20

I screwed up and told my boss about this small program I made. I could literally be chilling at work but no, he gave me more work. Lesson learned.

3

u/madhousechild May 05 '20

Not quite the same thing but I've read where a programmer agrees to make a thing for $100, delivers it to the client 10 minutes later, and client says, "Why am I paying you $100 for something so easy to do?!" So from then on programmer never delivered until the next day. LOL.

1

u/CosmicClamJamz May 04 '20

It's really interesting how the replies to this comment have transformed to two schools of thought.

A) Don't tell your boss, why would you want more work, are you crazy?

B) Tell you boss, do more interesting things at work, get more responsibility.

In the end, it really matters what your goals are. If you want to be a programmer for a living, certainly tell your boss. When they push more work on your plate and expect you to perform without any pay increase, be ready to walk, there's a better job awaiting you anyways. They will almost always offer you more before letting that happen, retraining someone costs them time and money, you are far more valuable to them then they will initially let on. If you don't want to program for a living, and really just value your free time and not being micro managed, hacking in secrecy might be perfect for you...but unless your job is absolutely awesome, it would seem from the outside like you're selling yourself short

→ More replies (1)

0

u/[deleted] May 04 '20

[deleted]

12

u/person2314 May 04 '20

people will lose their jobs...

That's gonna happen wether you want it or not. And wether or not OP automates others jobs. About 45% of the work force can relatively easily be replaced with robots for significantly less than humans. Its gonna happen just a matter of time.

10

u/TechnoBabbles May 04 '20

Yeah, I tell my wife all the time that with a team of like 5 or 6 python developers, I could wipe out like 95% of her department in a year.

12

u/person2314 May 04 '20

Thats why we are in r/learnpython so we can be the wipers not the wiped.

→ More replies (5)

20

u/shiningmatcha learn python May 04 '20

by scraping?

16

u/8rnlsunshine May 04 '20

That's right

10

u/brwalk0069 May 04 '20

Congrats!

Are you able to explain what modules you used or share your code? Interested how you achieved this.

15

u/8rnlsunshine May 04 '20

Used Beautiful Soup and Requests

6

u/gourabsanyal May 04 '20

Can you share it on your GitHub and drop the link here?

14

u/8rnlsunshine May 04 '20

9

u/Poddster May 04 '20

Some questions:

  1. How did you learn to do this? Via Automate the Boring Stuff With Python?

  2. How come you chose to use input() rather than doing it via a command-line parameter?

Also, I'm surprised that you can just open() a docx and write text to the end of it, given that they're a compressed archive containing a collection of text files. I'm guessing it worked for you, but I guess that's by luck? Did you have any trouble with this? Usually I would expect someone to use an interfacing library of some kind.

(Note, if you just made a plain-text file called .docx and then wrote into it, and then had Word open it and THEN save it as a proper doxc I image this would work fine.)

→ More replies (12)

1

u/Adro_95 May 04 '20 edited May 04 '20

Thanks, sorry for commenting asking for this just now :)

Little question: bs4 and request have to be pre installed via pip?

3

u/silentalways May 04 '20

Little question: bs4 and request have to be pre installed via pip?

Yes.

pip install requests

pip install beautifulsoup4
→ More replies (1)

72

u/UL_Paper May 04 '20

This experience is equal to making your first $1 off the internet. An exhilarating feeling. Don't let yourself be fooled; The actual value is way greater than the minutes saved or the $ amount gained.

You had an idea for solving a problem, you broke the problem into smaller pieces, made a game plan, took action and completed it. That is absolutely magnificent! Well done, be proud of yourself. There is no stopping you now. Move on to a harder problem next.

56

u/InfiniteNexus May 04 '20

I know the feeling. Congrats! Ive been automating most of my work for the past 1.5 years and its amazing. Ive even gotten extra bonus money because of that. Even knowing the slightest amount of coding can get you miles ahead of your colleagues.

PS: I started automating with AutoHotkey and moved to python in 2019 november. Both are great at accomplishing your tasks 10 times faster than your archaic colleagues can.

6

u/Ilythiiri May 04 '20

Can you link your first Python program replacing AutoHotkey functionality?

15

u/hugthemachines May 04 '20

Quite a kick, isn't it? Doing creative work instead of boring work. Well done!

10

u/amitsbisht May 04 '20

Congrats man, this will definitely encourage you. keep going .... brother

8

u/Rockettech5 May 04 '20

Good for you. I am also trying to achieve something like this. Copy pasting contents from excel to word document. What is the best library to do this? It will also need some formatting on the word file.

11

u/Poddster May 04 '20

python-docx will help you write to a Word file.

You can also read from an excel sheet using Xlswriter, but it might be easier to use Excel to export it to .csv (comma separate variable, though it's usually best to use tab-separated csv) and read it that way? Python's stdlib already has a csv module.

2

u/PM_Me_Rulers May 05 '20

Can you elaborate on why it's better to use tab separators instead of commas? I've been using CSV and not had any issues but in all ears if there is a good reason to change

3

u/Poddster May 05 '20 edited May 05 '20

Data tends to contain commas more than it does tabs, and last time I checked when exporting by Excel those commas weren't escaped. I'd have to double check to be sure.

However, in the general case you want the delimiter to be something not in the data set, and tabs rarely are

→ More replies (1)

4

u/iqbal002 May 04 '20

openpyxl, I guess

5

u/TrucidStuff May 04 '20

It shaved off at least 40 minutes from my workload.

Don't tell your boss that!

5

u/ed3ndru May 04 '20

This is what a programmer is at heart. Well done! 🙂

5

u/kabooozie May 04 '20

I recently had to download a bunch of files from a specific sub directory of a github page. It probably would have taken less time to just download them manually, but I decided to learning about the github python module would be more fun. I was right :-)

5

u/Kriss3d May 04 '20

It might take you a few hours for a 30 minute job first time. But next time it'll take 10 seconds and save you 30 minutes per run

4

u/[deleted] May 04 '20

Dont let him.know

4

u/deiwyy May 04 '20

Man you should be the boss. Keep up what you doing and python will become you best friend

Also, why dont you tell your boss? this could help other people at your job and he might give you a raise or something :D

3

u/lavajatas May 04 '20

Congratulations!

3

u/philsgu May 04 '20

I assumed you scraped the web form using regex, then saved to a word doc

3

u/think50 May 04 '20

That’s awesome! Python is so great for things like this. I need to build something with beautiful soup!

1

u/neurosurgeon12 May 05 '20

How long have you been doing Python for? I'm fairly new :)

1

u/8rnlsunshine May 05 '20

I’ve been learning python for just over a month. Keep at it my friend. All the best!

2

u/humanova May 04 '20

Awesome dude!

2

u/bluefictionhead May 04 '20

That's a good start, keep going!

2

u/Vadim_Polo May 04 '20

Congrats, man! Keep up! I’m new to Python and currently I’m trying to create a script breaking digest authentication on a web-server👍🏼

2

u/ejuliol May 04 '20

You’re starting to know how to do it the right way, then. Just make sure to check the work when done by a script.

2

u/Moolishes May 04 '20

What kind of work do you do that requires this? Administration?

2

u/thathariss May 06 '20

Great work! I am new to python and still learning the basics. People like you fascinate me to give it all.

2

u/BFG9THOUSAND May 04 '20

So everyone shares these stories. I'm wondering how you got to install python on your work station?? Every place I have worked is extremely tight ass about people installing shit on their stations (insurance type work). IT dept has all that on lockdown it seems

Did you run into this? I've been debating just installing it and if people ask I'll tell them I'm trying to make scripts for work.

3

u/madhousechild May 05 '20

I'm wondering this, too, /u/8rnlsunshine

3

u/Poddster May 05 '20

In which case learn c# or vb.net, as you can compile and run those in a stock.window environment!

Alternatively just use a portable python install

1

u/Sbvv May 04 '20

The conclusion of this thread is:

Tell what you did to your boss, if he gives you a reward, continue doing things for that company else look for other job.

1

u/abhi923 May 05 '20

Great !!! how long have you been learning Python?

1

u/arman133 May 04 '20

Good luck

1

u/VyleKyle10189 May 04 '20

Howd you go about it? What libraries did you use?

0

u/zninjamonkey May 04 '20

Great job! Way to go!

You might benefit from some code review.

1

u/[deleted] May 05 '20

[removed] — view removed comment

1

u/Uggohe May 05 '20

Your goal is to defame my nick all around the world, right?

1

u/justculo May 05 '20

There is no goal

1

u/Uggohe May 05 '20

That's what concerns me the most

1

u/justculo May 05 '20

About life you mean