I'm using this python script for import all the data to my application form a CSV file.
# -*- encoding: utf-8 -*-
#CSV ubication
csv_filename="route"
#django
ruta_django="route"
ruta_project = "route"
import sys,os
sys.path.append(ruta_django)
sys.path.append(ruta_project)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from gestion.models import Cliente, Oficina, Departamento
import csv
lectorCSV = csv.reader(open(csv_filename), delimiter=';', quotechar='"')
for fila in lectorCSV:
if fila[0] != 'cliente':
departamento = Departamento()
c = Cliente.objects.filter(nombre=fila[0])
o = Oficina.objects.filter(nombre=fila[1],cliente_id=c[0].pk)
departamento.cliente_id = c[0].pk
departamento.oficina_id = o[0].pk
departamento.nombre_departamento = fila[2]
try:
departamento.save()
except:
pass
In the CSV file there are words like "administración" and when it saves in the database it appears like: "Administraci?n"
i tried with # -- encoding: utf-8 -- but the problem persist.