Macs in Chemistry

Insanely great science

 

Dealing with Greek characters in column names.

Just a quick tip.

Sometimes I have a column in a Vortex workspace that I want to access via script where the title is something like

Microsomes (mouse) (Clint, µL/min/mg @ 5 µM)

However I get an error that it includes a non-ascii character, and there seems to be a difference in the way that Vortex displays and Jython (Python) handles these types of characters.

You can read more about the story behind Unicode representation of text here https://en.wikipedia.org/wiki/Unicode.

To avoid the error you need to explicitly set to UTF8. To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:

# -*- coding: utf-8 -*-

then any variables have to defined as unicode by preceding with a "u" string modifier as shown below.

col_mouseCl = vtable.findColumnWithName(u"Microsomes (mouse) (Clint, µL/min/mg @ 5 µM)")

You can read more details here https://www.python.org/dev/peps/pep-0263/.

Page Updated 20 April 2016