Posted by Mamutti on Mon 16 Nov 19:31
report abuse | download | new post
- def carregar(csvpath):
- '''Lê o arquivo csvpath e retorna um dict com os registros, onde as
- chaves são os termos e os valores os significados.'''
- termos = {}
- try:
- csvfile = codecs.open(csvpath, 'r', CODIFICACAO)
- except IOError, erro:
- if erro.args[0] == 2:
- # O argumento igual a 2 significa que o caminho fornecido não
- # existe ("no such file or directory")
- csvfile = codecs.open(csvpath, 'w', CODIFICACAO)
- else:
- raise ArquivosError('Erro de E/S: %s' % erro)
- else:
- reader = csv.reader(csvfile, dialect='default')
- for i in reader:
- termos[i[0]]= i[1]
- finally:
- csvfile.close()
- return termos
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.