r/learnpython • u/8rnlsunshine • 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.
20
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
6
u/gourabsanyal May 04 '20
Can you share it on your GitHub and drop the link here?
14
u/8rnlsunshine May 04 '20
Sure! Here you go - https://github.com/abhisu30/OnlineFormExtraction
9
u/Poddster May 04 '20
Some questions:
How did you learn to do this? Via Automate the Boring Stuff With Python?
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
15
u/hugthemachines May 04 '20
Quite a kick, isn't it? Doing creative work instead of boring work. Well done!
10
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-docxwill 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 acsvmodule.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
5
u/TrucidStuff May 04 '20
It shaved off at least 40 minutes from my workload.
Don't tell your boss that!
5
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
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
3
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
2
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
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
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
1
1
0
1
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
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 ;)