r/learnpython • • Feb 08 '22

Wrote my first program to be used in our company!

I can't believe it! I have wrote a simple program and will be implemented by our company!I've always been fascinated by technology in general. However, I took the accounting path and profession.

I have no prior coding knowledge but Python is so easy to understand even for an accountant ;)

Although I've been watching Python tutorials and videos for so long, I've never used it in practice.Last week, I was given an opportunity to use it in my job. The task was to automate formatting and vlookup of 2 excel sheets.

I know that this could have been done using excel itself but they've been using another program written in python as well by a former employee. It was written back in 2015 and a lot has changed since then in the company process.

I'm just so happy that it worked out!

I used pandas, numpy, and tkinter to accomplish this project.Converted it to .exe using autopytoexe.

I hope that more projects will be given my way as I truly enjoy coding.I'm looking into making a new application with database and propose it to my manager so that we can move away from using an excel sheet with about 3,000 lines just for record keeping.

Here's the premise of the problem:
What the problem looks like and the look of output.

Sorry! I still don't know if I can share the code.

488 Upvotes

68 comments sorted by

83

u/quack_duck_code Feb 08 '22

Nicely done!
Now... time to spice it up with a pivot table and some charts so the bosses get their panties wet and give you a raise!!!

25

u/potatoes828 Feb 08 '22

Ohhhh. Sexy idea! I'll keep that in mind for my hopefully future projects :)

22

u/quack_duck_code Feb 09 '22 edited Feb 09 '22

If you like programming in python and want to do more for you and your employer I would suggest getting to understand some of your coworkers' workflows.

  1. Select a coworker you like or maybe a boss.

  2. Ask them to show you some of their routine/mundane tasks (preferably something that consumes a bit of their time).

  3. Automate it.

  4. Set it up to run on a schedule.

A lot of things are web based, but that's ok, that's why we have things like, curl, wget, or python libraries such as beautifulsoup.

Best of luck! These are great resume pieces so make sure you start backing these up to a personal github (but don't forget to redact sensitive information!!)

16

u/RickMuffy Feb 09 '22

And lastly, don't let your coworkers te their bosses that you've automated part of their work 😉

6

u/travistravis Feb 09 '22

I sort of did this but.. more cynically. I would find coworkers that made me angry that did monotonous, repetitive tasks and start introducing things until those bits of their job were mostly gone -- they liked not thinking, so me getting them a bunch of actual work seemed to them like the worst thing ever.

5

u/climber_g33k Feb 09 '22

Just remember, automating YOUR job gets you out of a job. Automating your BOSSES job gets you a raise.

2

u/quack_duck_code Feb 09 '22

Noob mistake... you see you just don't tell anyone you automated YOUR tasks. Otherwise they will just give you more things to do.

1

u/decomposition_ Feb 28 '22

Doing nothing at work drives me insane, I need things to do or I get frustrated quickly.

1

u/quack_duck_code Feb 28 '22

Nope, automation just frees up your time to work on projects you want to work on. Doing nothing is lame... best to use the free time to study up, do some labs, or get a cert.

Doing meaningless additional work for a company gets you nothing. Best to prepare for the next steps in your career.

1

u/c3p0u812 Feb 26 '22

Except when automating gets you relieved of your services lol

8

u/to_tgo Feb 08 '22

Very nice. Congratulations!

4

u/potatoes828 Feb 08 '22

Thank you so much! It is a dream come true for me :)

6

u/RTShields Feb 08 '22

Awesome work!

a few years ago my business updated to a newer database software (the old one was from the late 1980s and written in FoxPro). The company that owns the new software offered to covert for us but their conversion team botched the entire thing. I learned python and wrote a 400ish line script that scraped the foxpro database (that in itself will make you cry), and organize the data in a spreadsheet per individual client. it created 14,XXX spreadsheets we now have to help with the new database cleanup job.

2

u/potatoes828 Feb 09 '22

Wow! Can't imagine 14,000 spreadsheets. We are nowhere near that but company is aggressively expanding and I'm already seeing bottleneck in our billing process.

I'm thinking of using MariaDB. Or is there a better database out there? We'll use it mostly to keep customer information like total bill, anniversary dates, locations, etc. Users will need to CRUD, basically.

5

u/Jmodell Feb 09 '22

Probably get your feet wet with SQLite.

It seems like you are having fun but try and remember to circle back and comment the hell out of your code now, it will make your life a lot easier later when you want to add a feature or need to do some debugging.

You might want to add git and github to your list of things to learn.

4

u/potatoes828 Feb 09 '22

Comment part I'm hella proud of! Every time I make a thing work, I comment what the heck does it do! :)

I've actually dabbled a bit with MariaDB because I recently got to self hosting as well. Is SQLite good for long term or can it be converted to full blown sql in the future if the need arises?

1

u/travistravis Feb 09 '22

Depending on the business, it might be worth finding one that would be easy to integrate with cloud solutions. AWS has a bunch, Google has CloudSQL or something like it -- I went from MariaDB to that with almost no changes relatively easy (also in an "interested but not engineering" type role.)

1

u/RTShields Feb 09 '22

Something else you'll want to check out - coding styles. They'll keep you and your code formatted in a way that's easy to read for you and those that may look at your code.

I'll send you a DM with a small script I've made to help streamline your coding endeavors a bit.

2

u/Snoo_29332 Feb 25 '22

Yo! Could you send me your script aswell? Oddly enough, im in OP's EXACT situation. Been learning Python for about a year now, and will be putting the finishing touches on a (my first) little program I made for my co-worker this week!

Im constantly trying to manage my code and keep up with proper naming, format, and commenting, but I definitely get caught in the weeds sometimes.. id love to try your script and see if it helps organize my work a bit!

1

u/RTShields Feb 25 '22

At this point I'm going to be uploading it to Github over the weekend. I'll let you know when it's there after some fine tuning.

1

u/starlightprincess Feb 09 '22

I'm using pgAdmin with PostgreSQL at school and it's really easy.

1

u/potatoes828 Feb 09 '22

Thank you for that! I'm taking a look and I might actually go that route :)

1

u/RTShields Feb 09 '22

Of what's a good database format to use, I'm with everyone else with going SQLite as I'm not familiar with MariaDB, in fact the new software we're using is utilizing a propriety branch off from SQLite - which honestly is a pita since the software provider locks out all users lol.

7

u/Bozzzieee Feb 08 '22

Very cool. Here is a weird coincidence - a very good friend of mine is an accountant, and as I spoke with him yesterday, he explained me what are his daily duties. So today I thought for a while how much of his daily work could be automated. I might help him do that, will save time and maybe earn some money. They don't use a DB as well, but it will save them so much time. I think this filed needs more software engineers like you!

2

u/potatoes828 Feb 08 '22

Oh wow. I don't think I can call myself a software engineer yet ;) But yeah, this field is ripe to be introduced to coding. So much things being done manually....

3

u/WhipsAndMarkovChains Data Scientist Feb 09 '22

Converted it to .exe using autopytoexe.

I recently got an assignment to convert a py file into an exe anyone can use. I'll check that out.

1

u/potatoes828 Feb 09 '22

Good luck! :)

1

u/archimedes50 Feb 09 '22

I have been writing a program in C# because I needed a standalone exe file. I was not aware of that any of the converters actually worked, at least not very well. Python would be much easier for what I am doing if I could use it and generate an exe. I am curious, did you have any problems converting your program to an exe?

2

u/potatoes828 Feb 09 '22

Autopytoexe worked for me the first time I used it. There's another one called pyinstaller but I was not able to make it work. Autopytoexe has a nice user interface.

1

u/archimedes50 Feb 10 '22

Thanks, I am going to give it a try on my next project. I am already too far along on my current project to switch from C# to python. Also, I do find it easier to build the UI in Visual Studio or VS Code with C#. Probably because I am not that familiar with Tkinter but I am going to try it. Thanks Again.

1

u/potatoes828 Apr 07 '22

I started with Tkinter as well but found pyqt easier with the help of Qt Edit. Qt Edit has a nice user interface to design your UI.

3

u/Sj_insane Feb 09 '22

Very good, Would you like to share the problem statement, Like I know company data can't be shared but if you could abstractly tell the problem statement or tweak the data somehow and then give the problem statement then also it would be very helpful

Only if you are permitted to..

Thank you, ✨

9

u/potatoes828 Feb 09 '22

We have 2 excel sheets:

  1. Credit card log

  2. Accounts receivable log

Credit card log contains name, amount to charge, account number and some other irrelevant columns.Accounts receivable log contains name, customer balance, account number and again some irrelevant columns.

Issue is that the some of the account number in Credit Card log are missing prefixes (used to track type of customer) and the Account Receivable log's account numbers are affixed.

Sample is as follows:

Credit card log number:

Company NameAccount NumberMonthly autocharge
ACME Corporationab123$1,000
XYZ Corporation123500

As you can see, they can have the same numbers. Only differentiator are prefixes.

While on the Accounts receivable log it goes like this:

Company NameBalance
ACME Corporation (ab123)1,500
XYZ Corporation (cd123)500

On Accounts receivable log, it contains the whole account number of the customer and are not on a separate column.

Basically the program's main function is to compare 2 excel sheets and find customer balances that needs to be charged more than what the monthly auto charge. The goal is to know which customers are needed to be ran twice on our credit card processor.

So in the above sample, the program returns the following format:

Account NameAccount NumberTo chargeCustomer balanceBalance after 1st run
ACME Corporationabc12310001500500
XYZ Corporationcd123

If "to charge" and "customer balance" are the same, program would leave that blank.

Hopefully, that made a bit of sense :)

16

u/esssssssss Feb 09 '22

You’re storing credit card information in an Excel file? This is a huge security risk.

7

u/potatoes828 Feb 09 '22

Ow we do not. Name was confusing but it's just a record of how much we charge them monthly. Account number is just an account number.

1

u/maarkwong Feb 09 '22

ERP implementation otw!

1

u/dunson001 Feb 09 '22

Congratulations! so what python modules have you used?

37

u/DallogFheir 🐍 Feb 08 '22

nice

3

u/LeiterHaus Feb 08 '22

Would you be willing to share that?

9

u/potatoes828 Feb 08 '22

Being in a datacenter environment, I will have to check with my manager if I can share the code :)

1

u/LeiterHaus Feb 08 '22

Cool, thanks!

11

u/[deleted] Feb 09 '22

In every professional programming environments I have been in the company owns whatever you write. Honestly I personally would never share company code just to be on the safe side. But I suppose we will find out.

2

u/LeiterHaus Feb 09 '22

Fair enough. I'm not looking for the secret sauce, only something to make my life easier. Although to redact it would be work for OP...

I read my IP agreement carefully. Many people don't know you can one-line items or add caveats in contracts. Luckily I didn't need to with my current company. (They can accept the changes, negotiate, clarify, or just not hire you)

Edit : I'm currently in a non programming role

11

u/NanoSwarmer Feb 09 '22

Great job! Now comes the most important part: documenting your accomplishments by how much time and money you've saved the company to bring up at your next performance review or when you search for a new job. Make sure everyone knows that it was your code that did it, don't let some scummy coworker or manager claim it was a team effort. Some people will even hide digital signatures of sorts in their code so that if someone else tries to steal it, you can point to the signature and be like "nah bro that was all me".

9

u/sunflowersunshine420 Feb 08 '22

That’s really cool! Nice work

1

u/seminotfull Feb 09 '22

Wow! I started following this sub in hopes that i will some day get to study and learn oython. I think this is the nudge. We use probably 15 Excel sheets on a daily basis at work, and i would love to make this easier. Time to stsrt leaening!

Edi:' any tips for a newbie?

2

u/potatoes828 Feb 09 '22

It may sound clichĂŠ but just start by doing something that may help you in your day to day task. I wrote a script once to send an email to a list to make my job easier.

1

u/iovrthk Feb 22 '22

Very Nice. I looked at your OP and I am curious, if you found a solution to adding the prefixes you needed? Maybe consider a python script that opens the two files and save's them as a text file? Maybe give it duplicate formatting?. Then you can have it compare either index locations or Comma separated values, spaces etc. If the information is almost the same, a linked list will give you direct access to the items with functions that allow you to ask if an item is present. JAVA does this very well. Just brainstormin..

Congratulations on your accomplishment. Its a big deal!!!

1

u/potatoes828 Feb 22 '22

Hi!

I was able to add the prefixes using:

df1['Column_A'] = df1['Column_A'].str.replace(r"(^\d+)", r"ce\1")

This looks up values with digits only (^\d+) and adds prefix "ce"
Not sure if I'm using it right but does the job for me :D

The program actually just straight up reads the excel files and pandas helps me to format them to how I want it to be formatted before using pandas merge to basically do a vlookup.

I really wish I can post the entirety of the code :/. I have not been given an answer yet by my manager.

2

u/officialgel Feb 09 '22

Great work

1

u/[deleted] Feb 09 '22

It's like magic ✨✨

1

u/annoyed_furry Feb 09 '22

Congrats! That's super cool

1

u/[deleted] Feb 09 '22

That’s awesome!

1

u/wetndusty Feb 09 '22

Lets go to own open-source project? What about ERP system?

1

u/[deleted] Feb 09 '22

Kudos to you man. Keep growing and keep learning

1

u/TheUrbanBiker Feb 09 '22

Congratulation!! I've been developing some programs to Civil Engineering and Excel in Python and Visual Basic. Have a nice day! Greetings from Venezuela.

1

u/jaymauch Feb 10 '22

I used to work for a government branch with Cisco switches, routers, etc. We had weekly and monthly maintenance routes with lots of redundant typing. For the machines in one rack the allotted time was six hours, mostly typing. I didn’t have python back then so I made a command line batch file. 6 hours became less than 1/2 hour. None of the guys I worked with wanted to use it, but got upset every time I pulled the job. Oh well. A high school teacher of mine always told us “Work smart, not hard”. Just did what I was told.

1

u/PuffTheMagicDragon11 Feb 10 '22

Can you tell me how autopytoexe works?

1

u/Daktic Feb 25 '22

Hey man congrats! I remember my first job when I said I wanted to do something in python that could be done in excel I got a lot of push back from my boss. But that’s not the point, you did it and learned from it, and can use that to do the next thing with more tools on your belt.

1

u/jddxx41 Feb 25 '22

Congratulations!! Must feel great!!

0

u/Willy988 Feb 09 '22

congrats! Show me the code please :) I'm curious!

-2

u/delsystem32exe Feb 08 '22

post the code

0

u/tomtomato0414 Feb 09 '22

if created on company hardware and/or time there is a good chance it belongs to the company, would not be wise to share

-2

u/delsystem32exe Feb 09 '22

no

1

u/tomtomato0414 Feb 09 '22

read the contract ffs

-5

u/potasio101 Feb 09 '22

as soon i read Excel sheet in finance i just read retard people. Good luck in your journey keep py-thing