Skip to main content

A statistics tool for your LOC per language

Project description


build status

A Python tool that tells you approximately how many LOC (Lines Of Code) you have written in a given language.

what is locstats?

Wondering how many LOC (Lines Of Code) you have written in a given language? Well, this is the tool for you! Given a programming language and a directory list, locstats calculates the amount of LOC you have written in that language.

installing locstats

You can install locstats via pip:

$ pip3 install locstats # Only Python 3 is supported!

Or you can build it directly from its sources by cloning this repo:

$ git clone
$ cd locstats/
$ pip3 install .

using locstats

Using locstats is pretty simple! Let's say I want to find out my LOC count in C given all the C projects I have inside my ~/code/C/ folder:

$ locstats c ~/code/C/
You have written approximately 39590 LOC in C.

But wait! I try to document the code I write, so there's gonna be a lot of lines of comments, which shouldn't count towards my actual code line count. I also try to format my code nicely, leaving blank lines where I have to to make it more readable; those do not contribute to the code line count either.

Thankfully, I can just run locstats in strict mode:

$ locstats c ~/code/C/ --strict
You have written approximately 28807 LOC in C.

Unsurprisingly, this returns fewer lines.

But what if I want to use the output of locstats in some other script? Well, I can tell it to give me minimal output, which will only print the LOC count (without the extra text):

$ locstats c ~/code/C/ --minimal

You can also get a detailed view of the LOC count per file using the -d or --detailed flag:

$ locstats python ~/code/locstats/         : 105 (32.71%)              : 73 (22.74%)         : 54 (16.82%)      : 47 (14.64%)            : 28 (8.72%) : 12 (3.74%)         : 2 (0.62%)
TOTAL LOC           : 321 (100%)


Do you want to contribute to an open source project? locstats needs your help! I've just started working on this project and there are still tons of things to add (mainly other programming languages in the languages.json file!).

So go ahead, fork this repo, write some code and make a pull request :)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for locstats, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size locstats-1.0.1-py3-none-any.whl (7.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size locstats-1.0.1.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page