Skip to main content
https://travis-ci.org/pitthsls/pycounter.svg?branch=master https://ci.appveyor.com/api/projects/status/lochuaf25fa9inru/branch/master?svg=true https://coveralls.io/repos/pitthsls/pycounter/badge.svg?branch=master Latest Version Documentation Status https://img.shields.io/badge/code%20style-black-000000.svg https://dev.azure.com/SPEARGH/SPEARGH/_apis/build/status/pitthsls.pycounter?branchName=master

pycounter makes working with COUNTER usage statistics in Python easy, including fetching statistics with NISO SUSHI.

A simple command-line client for fetching JR1 reports from SUSHI servers and outputting them as tab-separated COUNTER 4 reports is included.

Developed by the Health Sciences Library System of the University of Pittsburgh to support importing usage data into our in-house Electronic Resources Management (ERM) system.

Licensed under the MIT license. See the file LICENSE for details.

pycounter is tested on Python 2.7, 3.5, 3.6, 3.7 and pypy (2 and 3)

pycounter 2.x will be the last version with support for Python 2.

Documentation is on Read the Docs and the code can be found on GitHub.

Installing

From pypi:

pip install pycounter

From inside the source distribution:

pip install [-e] .

(use -e if you plan to work on the source itself, so your changes are used in your installation. Probably do all of this in a virtualenv. The PyPA has a good explanation of how to get started.)

COUNTER 5 Note

In this release, reports are output in COUNTER 4 format with COUNTER 5 data, which is wrong, and probably not a valid apples-to-apples comparison since, for example, TR_J1 excludes Gold Open Access counts that would be included in JR1, and also has HTML and PDF columns that will always be 0 because these are no longer reported.

Before the 3.0 release, it should be capable of producing actual COUNTER 5 reports, probably with an API for getting COUNTER 4 style data compatible with scripts that were making assumptions about the data received to pass it into another system.

Usage

Parsing COUNTER reports (currently supports COUNTER 3 and 4, in .csv, .tsv, or .xlsx files, reports JR1, JR2, DB1, DB2, PR1, BR1, BR2 and BR3):

>>> import pycounter.report
>>> report = pycounter.report.parse("COUNTER4_2015.tsv")  # filename or path to file
>>> print(report.metric)
FT Article Requests
>>> for journal in report:
...     print(journal.title)
Sqornshellous Swamptalk
Acta Mattressica
>>> for stat in report.pubs[0]:
...     print(stat)
(datetime.date(2015, 1, 1), 'FT Article Requests', 120)
(datetime.date(2015, 2, 1), 'FT Article Requests', 42)
(datetime.date(2015, 3, 1), 'FT Article Requests', 23)

Fetching SUSHI data:

>>> import pycounter.sushi
>>> import datetime
>>> report = pycounter.sushi.get_report(wsdl_url='http://www.example.com/SushiService',
...     start_date=datetime.date(2015,1,1), end_date=datetime.date(2015,1,31),
...     requestor_id="myreqid", customer_reference="refnum", report="JR1",
...     release=4)
>>> for journal in report:
...     print(journal.title)
Sqornshellous Swamptalk
Acta Mattressica

Output of report as TSV:

>>> report.write_tsv("/tmp/counterreport.tsv")

Development

Our code is automatically styled using black. To install the pre-commit hook:

pip install pre-commit

pre-commit install

Release files for pycounter 2.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycounter 2.1.4
File Size Uploaded
pycounter-2.1.4.tar.gz 83.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycounter 2.1.4
File Interpreter ABI Platform
pycounter-2.1.4-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 126.9 kB

Release files / pycounter-2.1.4.tar.gz

Download URL pycounter-2.1.4.tar.gz
Size 83.5 kB
Tags Source
SHA-256 checksum
How to use checksums
45dba61c32e6c027953547e6c293b674debb25954954ee3025d37c9fdde42ba9
BLAKE2b-256 checksum
How to use checksums
5b63b07d4d788b7e5dbd37aaa871f361ce9a00ace0c4379e08b9ba296ab58281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

Release files / pycounter-2.1.4-py2.py3-none-any.whl

Download URL pycounter-2.1.4-py2.py3-none-any.whl
Size 43.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
369330b695e65d5aeb90564876e6a90421c1f62474e50db581c07f7a79499c65
BLAKE2b-256 checksum
How to use checksums
82e826ea30177d411dc8473cb497297b19d076721844e9228cd3ac9bdb26cdcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page