Simple Docker container that outputs the Work From Home percentage for each timesheet pdf in a folder.
Run the docker container from within the folder that contains your timesheet pdfs:
Unix/MacOS:
docker run -t -v $(pwd):/data strombringer/timesheetWindows:
docker run -t -v ${pwd}:/data strombringer/timesheetThe -t parameter is only needed for the highlighting of the current home office quota. Skip it, if you don't need that.
| Name | Python Shortcut | Environment Variable (Docker) | Default | Description |
|---|---|---|---|---|
| -quota | -q | TIMESHEET_QUOTA | 70 | Home Office quota |
| -dateformat | -d | TIMESHEET_DATEFORMAT | %d.%m.%Y | Date format of the dates in the first line of the input files (e.g. 01.07.2024 |
| -format | -f | TIMESHEET_FORMAT | text | json | text = nicely formatted report table, json = all values of the report as a json document |
| -vacation | -v | TIMESHEET_VACATION | single days, date ranges or a start date until the end of the month. mix and match as you want. e.g. 12,15-19,22- (day 12, and 15 to 19, and 22 until the end of the month) |
Use the keys from Name or Python Shortcut as arguments when calling the Python script directly:
cat output.txt | python process_timesheet.py -f json -quota 50 | jq .or environment variables when using the Docker container
docker run -t -v $(pwd)/data:/data -e TIMESHEET_QUOTA=50 timesheetor an environment file (see config.env.tpl) with Docker
docker run -t -v $(pwd)/data:/data --env-file config.env timesheetdocker build -t timesheet:latest .If the output is not what you expect, run the included commands one by one.
You need pdftotext, which you can install on Linux with
apt-get install poppler-utilsand MacOS with
brew install popplerYou also need the Python packages listed in requirements.txt
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -Ur requirements.txtRun the file input.pdf through pdftotext and write the result to output.txt
pdftotext -layout input.pdf output.txtPipe output.txt through the python script
cat output.txt | python process_timesheet.pyOutput pdftotext to stdout and pipe that directly through the Python script:
pdftotext -layout input.pdf - | python process_timesheet.pycat output.txt | python process_timesheet.py -f json | jq .