Working with medical data means that I often have to convert between SI units and (outside of the medical community) lesser known units, such as Pa and mmHg for pressure. To simplify unit conversions and non-dimensionalsation for myself, I use a .cfg file that contains both unit conversions and parameters, which can be read by the
[Units] section is parsed first and entries are added to a dictionary iteratively. Each
value is parsed using
eval() with the dictionary. This means that previously encountered entries are automatically evaluated.
Below is a simple example of a .cfg file containing units and parameters and the corresponding code to parse the file.