Tuesday, December 27, 2016

A Taste of Things to Come

Happy holidays!

I wanted to give a little preview of the things to come, and explain where I plan to take this blog in 2017. My current plan is to focus the blog posts on three areas, with the majority in #1 or #2:
  1. Learning Python (aka Getting Started with Python4CPAs): Learning oriented posts focused on helping newcomers to Python get started. The examples will be geared toward accountants, however they will be applicable to anyone looking to learn Python. 

  2. Using Python in Accounting: These posts will mostly explore the meat of where Python really shines, and where it will be the most awesome for CPAs, which are the modules. The quick and dirty: you can "import" various modules into your code, and add the ability to implement some incredibly powerful capabilities with just a few lines of code.  Python at its core comes with standard modules in its "standard library", which has tons of awesome things in it. Then there are the 3rd party modules, which can be easily downloaded from pypi, which currently has over 95,000 Python packages! We'll explore which modules from both the standard library and pypi are most useful and how to use them, and then how to link them together.

  3. Everything Else: the other posts will be for posts that don't fit into the first two categories, like this post, or real life examples of Python in accounting, general observations, or other big picture topics.


What's comping up the pipeline?


Here's a sample of what we've got planned:

Learning python
  • Python basics: lists, dictionaries, tuples, and functions
  • Resources for Python learning outside the scope of this blog
  • Installing and managing 3rd party packages

Using Python in Accounting
  • Jupyter Notebook - Documenting code, analysis, and results, and how it can be used in an audit
  • Pandas (aka the Excel killer) - Importing, analyzing, and viewing tabular data 
  • Importing PDF files using regular expressions
  • Pyautogui - Automating repetitive tasks to save time and sanity

As always, suggestions and questions are welcome. 
Follow me @python4cpas and @dtizzlenizzle!


Cheers!
Daniel

Friday, December 2, 2016

Getting Started with Python4CPAs: Step 2 - Write a Simple Program!

Hello again, fellow CPAs and accountants, it's time to write some code! If you haven't already done so, download and install the Anaconda Python 3 distribution package.





NOTE: If you are new to programming, definitely start the journey here. If you've done some programming before and know a little Python already, feel free to skip ahead to a later step.




Let's Get Coding!



We will start with a simple Python editor called IDLE that you should now have on your machine.

To start, open Windows run (windows key + r), type in 'idle', then hit enter.


Starting IDLE in Windows


🍎If you're a mac person, open terminal, type 'idle3', then enter.🍎



Here's what your shell should look like. Make sure it says "Python 3.X", and not "Python 2.X"
Python 3.x Shell


From the Python Shell, go to File > New File

This opens up the Editor window of Python IDLE. Now you have two windows open: one for the editor, and one for the shell, where the results of the code will be displayed.

Arrange your editor and shell as shown above so they're easy to work with.




From the editor window, save the file with the name 'program.py' or any name you like.


Hello, World!


Let's get started with the old tried and true "Hello world" program. The traditional version of this program prints the statement "Hello, world" to the screen. But because we are Python4CPAs, we get to have a little fun and I'll add an accounting twist. In writing these seven lines of code, you will learn about:
  • creating and saving a new python file in IDLE
  • accepting a user input() and storing it in a variable
  • performing a math calculation and storing the result in a new variable
  • the print() statement
  • string format() method

In the editor, type the following
(See if you can guess what it does as you type it. )

name = input('What is your name? ')
debit = 5000
credit = 3500
net_balance = debit - credit
print('Hello, {}!'.format(name))
print('Debits are {} and Credits are {}'.format(debit, credit))

print('Net balance is {}. Laterz!'.format(net_balance))

Once you've typed in your code as above (if you're lazy you might have copied/pasted), hit F5 to run the file. It will make you save first, and then it will run in the Shell window. When it prompts you, type in your name!




Did it work?

If you entered the code as shown above, the shell should display something like this:



CONGRATS! You just wrote a program!


Here's a little breakdown on how the program works.


name = input('What is your name? ')

The input() prompts the user to type something in, and by using a variable name and '=', the user's input is saved to the variable called "name"



debit = 5000
credit = 3500 


Here we are assigning the numbers 5000 and 3500 to variables debit and credit. These are called "int" type, or integers, and they do not have decimals. We'll get much heavier into numbers in the next few sessions.



net_balance = debit - credit

Python can do math, hooray! Here we are subtracting the credit variable from the debit variable, and putting the resulting calculation into a variable called "net_balance".



print('Hello, {}!'.format(name))
print('Debits are {} and Credits are {}'.format(debit, credit))
print('Net balance is {}. Laterz!'.format(net_balance))

Here are our three print() statements. Print statements must use parenthesis, and any strings printed must be within quotation marks (Python accepts single or double quotes).

We've gotten a bit fancy here and used a neat feature called the format() method. Format() allows you to insert open/closed brackets within a string as a placeholder, and then you can pass variables through to those placeholders by putting them in the parentheses of format(), separated by commas. If we just wanted to print a simple hello, it would just be print('Hello')

Note how the format method is attached to the string with a period. This is common in programming languages and python as well, and just means we are calling the format method on the string. But you don't worry about all that today. For now, just get it to work, print out the results, and put them up on your fridge.


I encourage you to play around with this program, change the numbers, change the print statements, and just have fun. That's the best way to learn something new.


Great job!


Well, that's it for this one. Next time we'll get more advanced, and before too long we'll get you doing something that actually might be useful in your job, hopefully!

Questions? Suggestions? Please leave me some feedback! 

Also please sign up for the RSS feed, and follow me on twitter - @python4cpas and @dtizzlenizzle

Sunday, November 27, 2016

Getting Started with Python4CPAs: Step 1 - Get Python

Welcome to the Getting Started with Python4CPAs series. Here we will help you through the process of downloading, installing, and writing your first program with Python. If you have trouble at any point in the process, try googling it. Your new best friend is a website called stackoverflow.com

Get Python through Anaconda

Anaconda is a distribution package that includes Python, a bunch of useful packages, and some other really useful goodies that we may use later on. Go to Anaconda's download page and download Python 3. If it asks, make sure to add Python to your computer's path.

Why not Python 2? Because Python 2 will no longer be supported after 2020. 

Try Python Online

Don't want to download Python onto your computer yet? Your IT department won't let you install unapproved applications? Bummer. You won't get the full benefit of using Python until you install it on your computer, but at there are a few alternatives for now to try it out online:
  • Go to repl.it - it seems to have a full Python 3 IDE with some additional packages available 
  • Head over to python.org and click the yellow box-like icon to launch the Python 3 shell 
  • Sign up for a free account at pythonanywhere, and open up a Python 3 console

Congratulations! You're ready to start writing some simple Python code! Let's give it a shot, shall we?

Tuesday, September 6, 2016

Data Analytics, Automation, and the Future of Accounting

It looks like some of the accounting folks out there are starting to realize how important data analytics and automation are to the accounting profession, and it's refreshing to see this! While I think we're still a ways to go before we see any major changes, it's at least a step in the right direction that there are some good articles getting written on the topics. These two articles piqued my interest and thought I would share.

Prospecting the Next Machine Age  - Finding CPAs’ role in the technological future. (Accounting Today)

To me, this article is saying automation is going to play a heavy role in the future of the accounting practice, and we shouldn't fear it. Instead, we should embrace it. I agree, and I think Python can play a huge role in helping provide all accountants with some basic automation tools at no cost, other than the time it takes to learn to use Python.

The next frontier in data analytics  - Why CPAs and organizations need to learn to use advanced technology to predict and achieve outcomes.  (Journal of Accountancy)

This article is a nice overview and discussion on data analytics in accounting and auditing. It mentions IDEA, ACL, and Excel as three tools commonly used in data analytics, but like most other places I've been reading about data analytics in Accounting, it doesn't mention Python. IDEA and ACL are very powerful and useful tools, but not cheap. Most accountants have Excel, but it's very limited. Python provides a nice middle ground that I think will help get a lot of the accounting firms and accounting departments to the next frontier if they don't have access to ACL or IDEA.

The article ends with the line "CPAs, whether working in public practice or industry, will enhance their career opportunities through the acquisition of additional data analytics expertise." Enter Python, the best tool for this job in my opinion.

........................

So what now? Stay tuned! I'm planning my next post as a super basic intro to Python for the non programmer, which will discuss the various ways to access Python, and will provide a few simple programs to try out. Sign up to receive an email notification when I add new posts!

Saturday, July 9, 2016

Hello world!

Hi there! I'm Daniel. I'm a CPA, and I love playing music, running, rockclimbing, and most recently I have an obsession with Python. So much so that I decided to start a fun little blog to document my adventures with exploring its usefulness in the accounting world.

If you're an accountant who has never heard of Python or have heard of it but not really used it much, this is the blog for you. And I encourage feedback and suggestions on future topics so we can explore Python together. Send me any ideas you have to python4cpas@gmail.com.

I anticipate getting down and dirty in the code shortly, but I will have to decide what topics to get into first, and how to do it.

For now, I'd recommend checking out some of the great free resources online, such as my favorite, Rice University's courses on Coursera or another good one is Univ of Michigan's course also on Coursera.

My Python use is very heavily data driven, more on numbers than words, and often involve data pulled from PDF files. I plan to cover some generally useful topics (like how to foot a 600 page PDF file in a matter of minutes, or how to take a general ledger in CSV format and import it into Python, summarize on certain data elements, and export the summarized data into an excel file), and some very specific topics (like how to grab the stock sale transactions from a Wells Fargo 1099, turn it into a table format, and export it into excel, or how to grab stock prices for certain stock tickers on a specific date).

The posts will likely be in one of the following categories:

Tax stuff
Audit/financial statement stuff
Other generally useful stuff

Looking forward to some fun Python exploring!

Cheers,
-Daniel