1

I have vectorial data that I have loaded in qgis setting as UTF-8. I was checking if the values of field in atribute table is standartized. So I am creating a script to do it. However, when I print list of field all alfa atributes values are printed so stranged. Look below:

Baixão Lagoa Grande Baixão Mundo Novo Baixão da Bandeira Baixão da Panela Baixão da Planta Baixão da Serra Baixão da Solta Baixão das Queimadas Baixão do Campestre Baixão do Feijão Baixão do Pontal Baixão do Umbuzeiro Baixão do Xique-Xique Baixão dos Caboclos Vereda da Espadeira Vereda da espadeira

I encoded this values to 'latin' and they become well when I print one by one element of my list. For example: Baixão Lagoa Grande.

However I need one list with all of them. So I made this:

idx = l.fieldNameIndex('nome')
values = l.uniqueValues(idx)
lista_nome = []
for v in values:
    print str(v.encode(encoding='latin1'))
    lista_nome.append(str(v.encode(encoding='latin1')))
print lista_nome

The result has been all characters so messy again, like the firt print that I showed (for example: Baixão Lagoa Grande)

How to correct this characters?

3
  • Can you load the layers with Latin1 instead of UTF-8?
    – underdark
    Commented Oct 31, 2016 at 19:19
  • I know that vector was produced in UTF-8. This is the reason to load it like this. Commented Oct 31, 2016 at 20:21
  • @underdark I did what you advice me. The problem continued. I haven't understanded why encode of string in list are so wrong. When I print them alone they are well written. Commented Nov 1, 2016 at 20:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.