Skip to main content

Python package

Topper

Topper is a library made to parse and process log files of music listening. The purpose of this application is to get the top 50 songs the most listened on the last 7 days grouped by country or user id.

You must provide:

  • landing_folder: where daily files are sent
  • checkpoint_directory: used by the application to process, archive and persist data across days
  • output_directory: where result files are written everyday
  • mode (optional): country (default) or user is the aggregation mode

Input files

Each log file must match the pattern listen-YYYYMMDD.log. The file must contains data structured with:

  • One row per stream (1 listening).
  • Each row is in the following format: song_id|user_id|country

File management

Input files will be moved to the directory checkpoint/current/

Invalid files will be moved to the directory checkpoint/errors/

Data files older than 7 days will be moved to the directory checkpoint/archive/

Output files

Mode 'country'

Produced files have the following format:

country1|sng_id1:n1,sng_id2:n2,sng_id3:n3,...,sng_id50:n50
country2|sng_id1:n1,sng_id2:n2,sng_id3:n3,...,sng_id50:n50

Where country is the country ISO2 code, sng_id1:n1 the identifier of the song the most listened with the related number of streams, sng_id2:n2 the identifier of the 2nd song the most listened with the related number of streams and so on..

Mode 'user'

Produced files have the following format:

user_id1|sng_id1:n1,sng_id2:n2,sng_id3:n3,...,sng_id50:n50
user_id2|sng_id1:n1,sng_id2:n2,sng_id3:n3,...,sng_id50:n50

Where user_id is a user, sng_id1:n1 the identifier of the song the most listened with the related number of streams, sng_id2:n2 the identifier of the 2nd song the most listened with the related number of streams and so on..

Usage

Supported Python Versions

Python >= 3.6

Installation

virtualenv -p python3 venv
source venv/bin/activate
make install

Display usage

topper -h

Example

topper --landing_folder sample/ --checkpoint_directory checkpoint --output_directory output --mode country

Development

make test # coverage tests
make linter # runs pylint
make build

Release files for topper 1.1.1

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

Source distribution (sdist)

Source distribution for topper 1.1.1
File Size Uploaded
topper-1.1.1.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for topper 1.1.1
File Interpreter ABI Platform
topper-1.1.1-py3.8.egg Legacy Egg format - - Details

Total release size: 28.1 kB

Release files / topper-1.1.1.tar.gz

Download URL topper-1.1.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f70a0f1fa46b999840539921d3f5d1ad0247aef5ff700dcaf540e2f5a80778f1
BLAKE2b-256 checksum
How to use checksums
aa012e98cd8aaf28dd1b1d905eafea5621c0ae45d3e1019cd1c4bb8f6d494856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / topper-1.1.1-py3.8.egg

Download URL topper-1.1.1-py3.8.egg
Size 17.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
4edeb23a62538fcf97164f405b6b0979f1491aba4941df429de097d34f35c7f0
BLAKE2b-256 checksum
How to use checksums
330b67114ed9c017f6c9b239e8ae5a3c3853fb1d87eb21d8f353b6bfbb7c9968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.1

2 release files

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