okfn-brasil / jarbas

🎩 API for information and suspicions about reimbursements by Brazilian congresspeople
https://jarbas.serenata.ai/
296 stars 61 forks source link

Import of sample files fails on windows #243

Closed lucaslm closed 7 years ago

lucaslm commented 7 years ago

Following the instalation tutorials on README file, when running manage.py on windows, for some reason the python interpreter assumes a wrong encoding. Bellow is the produced output:

> python manage.py reimbursements contrib\sample-data\reimbursements_sample.xz
Starting with 1,000 reimbursements
Processed: 0 lines
Updated: 0 reimbursements
Created: 0 reimbursements
Skip: 0 reimbursements
Processed: 0 lines
Updated: 0 reimbursements
Created: 0 reimbursements
Skip: 0 reimbursements
←[F←[F←[F

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_comma
nd_line
    utility.execute()
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\SAMSUNG\Documents\jarbas\jarbas\core\management\commands\reimbursements.py", line 27, in handle
    self.create_or_update(self.reimbursements, status)
  File "C:\Users\SAMSUNG\Documents\jarbas\jarbas\core\management\commands\reimbursements.py", line 85, in create_or_upda
te
    for reimbursement in reimbursements_as_dicts:
  File "C:\Users\SAMSUNG\Documents\jarbas\jarbas\core\management\commands\reimbursements.py", line 35, in reimbursements

    for row in csv.DictReader(file_handler):
  File "C:\Program Files\Python36\lib\csv.py", line 111, in __next__
    self.fieldnames
  File "C:\Program Files\Python36\lib\csv.py", line 98, in fieldnames
    self._fieldnames = next(self.reader)
  File "C:\Program Files\Python36\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3856: character maps to <undefined>
cuducos commented 7 years ago

Closed by #244