iNTERFACEWARE Products Manual > Installing and Using Chameleon > Using Python Scripting > Python Scripting Examples > String Manipulation > Converting Code Sets Using Conditional Statements |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
A common problem is how to convert one set of codes from one type to another. For example, if you are processing the sex of a patient, you may need to convert M to 0 and F to 1. The following code fragment uses conditional statements to implement this (remember to correctly indent the statements):
While this solution is useful for small code sets, conditional statements can become difficult to manage if the code set is large. For larger code sets, it is easier to use a dictionary to map one code to another. For more information on using dictionaries to map code sets, see Converting Code Sets Using a Dictionary.
|