A mixed bag of PMA2020 utilities. There are several functionalities all based on working with spreadsheets. The main features are the following:
Formerly qlang
, this package has been renamed and expanded to provide new
functionality and new command-line tools. The command line tools are described after installation.
This version requires Python 3 or later. Python 2 is not supported.
This package is on PyPI! Run:
python3 -m pip install pmix
For developers, to install from Github, run:
python3 -m pip install https://github.com/PMA-2020/pmix/zipball/master
Usage
python3 -m pmix.analytics FILE1 [FILE2 ...]
creates a JSON file describing the prompts and fields for analytics.
The purpose of the Pmix Borrow module use to assist with translation management of ODK forms. It is especially useful for merging translations from one file into another.
This module is called with
python3 -m pmix.borrow
and it does two things. Without the -m
argument, it simply creates a
translation dictionary. The source string is in the first column, and the
target languages are in the subsequent columns. With the -m
argument,
it creates a translation dictionary and then merges those translations into
the file specified by -m
.
- Without
-m
,
python3 -m pmix.borrow FILE1 [FILE2 ...]
creates a translation dictionary from FILE1 [FILE2 ...]
.
- With
-m
,
python3 -m pmix.borrow -m TARGET FILE1 [FILE2 ...]
creates a translation dictionary from FILE1 [FILE2 ...]
and then merges into TARGET
.
In both examples, a default output filename is used, but one can be specified with the -o
argument.
The input file can be 1 of 2 kinds:
- A standard ODK file.
- A raw translations file.
A raw translations file has the following form, using English and French as examples:
text::English | text::Français | ... | text::<language n> |
---|---|---|---|
Hello! | Bonjour! | ... | <"Hello!" in language n> |
There are a set of command-line options to work with diverse translations.
-D
This option, used without argument, means if text has diverse translations, do not borrow it. Only has effect with-m
-C CORRECT
This option marks a file as correct. Fill inCORRECT
with a path to a source file. Its translations are given precedence over others. If there is only one input file, and it is correct, then there is no need to mark it correct because nothing can override it.d DIVERSE
Give a language found in the forms forDIVERSE
. This option is used without-m
. It creates a file with only strings that have diverse translations in the supplied language from the source files.
A resultant file with merged translations has the following possible highlighting:
- Orange if the source and the translation are the same.
- Blue if the new translation changes the old translation.
- Grey if the new translation fills in a previously missing translation (blank cell).
- Green if the translation is not found in the TranslationDict, but there is a pre-existing translation.
- Red if translation is not found and there is no pre-existing translation.
- Yellow if using the
-D
option, shows strings that have diverse translations without inserting them. - No highlight if the translation is the same as the pre-existing translation.
Usage
python3 -m pmix.cascade FILE
creates a new Excel spreadsheet after converting geographic identifiers from wide format to tall format.
Use the numbering mini-language and create question numbers for an ODK survey.
python3 -m pmix.numbering FILE
The program then looks for a column entitled "N" in the "survey" worksheet. It creates numbers based off of the directives there and adds them to label columns.
There following features are offered:
- Convert a worksheet to CSV with UTF-8 encoding and UNIX-style newlines.
python3 -m pmix.workbook FILE -c SHEET
- Remove all trailing and leading whitespace from all text cells
python3 -m pmix.workbook FILE -w
A utility for showing the differences between two Excel files.
python3 -m pmix.xlsdiff FILE1 FILE2 --excel
The above command creates a new Excel file, creating a new version of FILE2
with highlighting to show differences.
Red -- Rows and columns that are duplicate so are not compared
Orange/Peach -- Rows and columns that are in the marked up file (FILE2
), but not in the other
Light Yellow -- Cells that are different between the the two files
Green -- Rows that are in a changed order
Short Flag | Long Flag | Description |
---|---|---|
-h | --help | Show this help message and exit. |
-r | --reverse | Reverse the order of the base file and the new file for processing. |
-s | --simple | Do a simple diff instead of the default ODK diff. |
-e | --excel | Path to write Excel output. If flag is given with no argument then default out path is used. If flag is omitted, then write text output to STDOUT. |
Viffer is a tool that provides a tabulated report on the differences between two XlsForms. Viffer stands for "Version Diff'er".
This tool is currently under development under another fork of pmix. If interested in using it, please see: https://github.com/joeflack4/pmix/tree/feature_viffer#viffer
Generate a Viffer report.
python -m pmix.viffer old_form.xlsx new_form.xlsx
Submit bug reports to James Pringle at jpringleBEAR@jhu.edu minus the bear.