Skip to main content

Parse Troopmaster export files into TOML, YAML, or JSON

Project description

tm_parser

(c) Michael Perkins, 2023, 2024

Introduction/usage

Parses an advancement/individual history PDF from troopmaster, into YAML/TOML/JSON format or for use in Python projects. Also hooks into the objexplore browser for data checking/viewing.

Installation

pip install tm-parser

Instructions:

In troopmaster, under reports -> advancement -> individual history

  • select all the scouts you want to report
  • select all the ranks you want to report
  • Do not select "Omit details on completed ranks"
  • Other than that, any other options can be included or excluded (I only tested a few configurations. if it doesn't work, select everything)

generate the report and save it to a PDF. -- we will use "export.pdf" as the output file name

by default, the output is to the console in YAML format

Then run:

tmparse -o output.yaml export.pdf

Options:

-t --output-type  [yaml], json or toml

-o --outfile output filename

This produces output of the desired type.

-e --explore opens an objexplore window for your scouts so you can explore the data

YAML can be read in python with:

import yaml

with open('output.yaml') as f:

    scouts = yaml.safe_load(f)

Using tm_parser in code:

from tm_parser import Parser

#initializing the parser automatically parses the file and stores
#the information in TmParser().scouts
parser = TmParser(infile='filename.pdf')


# Iterating on the parser yields scouts
for scout in parser:
    print('----------------------------------------------')
    print(f"{scout['Data']['Name']:26}Date       Eagle Req")
    print('----------------------------------------------')
    ## do something with scout
    if "Merit Badges" in scout:

        #sort merit badges by date ascending
        for badge, data in sorted(scout['Merit Badges'].items(), 
                                    key=lambda x: x[1]['date']):
            print(f"{badge:26}{data['date']} {data['eagle_required']}")

Yields:

----------------------------------------------
Smith, John               Date       Eagle Req
----------------------------------------------
Climbing                  2017-03-11 False
Mammal Study              2017-06-29 False
Leatherwork               2017-06-30 False
Swimming                  2017-06-30 True
Kayaking                  2018-06-29 False
Wilderness Survival       2018-06-29 False
Rifle Shooting            2018-06-29 False
First Aid                 2018-09-29 True

By default the information is a dictionary, with the scout names as keys, and each scout is a dictionary with the following keys:

  • Activity Totals
  • Data - contains biographical data
  • Leadership
  • Merit Badges
  • Order of the Arrow
  • Partial Merit Badges
  • Rank Advancement
  • Training Courses

All dates have been parsed into datetime.date objects, in YYYY-MM-DD format, and are null if not assigned in the incoming data.

Project details


Download files

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

Source Distribution

tm_parser-0.23.1.tar.gz (88.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tm_parser-0.23.1-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file tm_parser-0.23.1.tar.gz.

File metadata

  • Download URL: tm_parser-0.23.1.tar.gz
  • Upload date:
  • Size: 88.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.2 HTTPX/0.28.1

File hashes

Hashes for tm_parser-0.23.1.tar.gz
Algorithm Hash digest
SHA256 808530e3b6df1625dc6a3869e41c6fc92337bc9b7d976fc837bb539940fe9f0b
MD5 667d7c6b9b69e1b0db97b02f04e3ad25
BLAKE2b-256 ec349c931ce9f9e765adf7380724e276a88f42e5e6f1899d22d7d492eeb13e85

See more details on using hashes here.

File details

Details for the file tm_parser-0.23.1-py3-none-any.whl.

File metadata

  • Download URL: tm_parser-0.23.1-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.2 HTTPX/0.28.1

File hashes

Hashes for tm_parser-0.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c557314331d5ce4c5233e9a613b12f076ccd185dcd81e3f862e6f1c0ae83f7e
MD5 3d17f37f394501af68b90639d4acc9a2
BLAKE2b-256 3c7b02684b16d6ad3bb3324612ca781def582c0aa82f70571a1c005c7f793ef1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page