Reading the tag error due to special characters in tag

Hi

i have list in that one tag have special characters

allTags = ['Raw Materials/ROCK FEEDING/Conveyors/Belt_PV_Débit sur le T9',
           'Raw Materials/ROCK FEEDING/Conveyors/Belt']

code i am using

PathsList = [tVal.value for tVal in system.tag.readBlocking([path+".OPCPath" for path in allTags])]

error
Traceback (most recent call last):
File "", line 14, in
ValueError: Invalid path element 'Raw Materials/ROCK FEEDING/Conveyors/Belt_PV_Débit sur le T9': Illegal character '©' (Line 1 , Char 95)

can any help me to skip the error and run the for loop for other tags

i need to read 200 tags .my one liner script works very faster that's why i am using that without using try and except

Try adding a u before strings that contain non-ascii characters:

paths = [u"path/to/tags", u"some/other/tag"]

But really, REALLY, you should avoid any exotic character in tags paths. If you can't use it as a python variable name, don't use it in a tag path. That means no spaces, no dashes (-), no slashes, brackets, parentheses, tabs, dots, accents, emojis, etc.

It's not always possible to change them when they've been used all over the project and/or they're historized, in this case try the unicode thing.

1 Like

Thanks for the solution, Its working

added unicode in script

PathsList = [tVal.value for tVal in system.tag.readBlocking([unicode(path)+".OPCPath" for path in allTags])]