diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 16 | 
1 files changed, 8 insertions, 8 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 6082fb4e0..01b46b7ae 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2532,20 +2532,20 @@ class Import(models.Model):              tmpdir = tempfile.mkdtemp(prefix='tmp-ishtar-')              imported_file = z.extract(filename, tmpdir) -        with open(imported_file) as csv_file: -            encodings = [self.encoding] -            encodings += [coding for coding, c in ENCODINGS] -            for encoding in encodings: -                try: +        encodings = [self.encoding] +        encodings += [coding for coding, c in ENCODINGS +                      if coding != self.encoding] +        for encoding in encodings: +            try: +                with open(imported_file) as csv_file:                      vals = [line                              for line in unicodecsv.reader(csv_file,                                                            encoding=encoding)]                      if tmpdir:                          shutil.rmtree(tmpdir)                      return vals -                except UnicodeDecodeError: -                    if encoding != encodings[-1]: -                        csv_file.seek(0) +            except UnicodeDecodeError: +                pass  # try the next encoding          if tmpdir:              shutil.rmtree(tmpdir)          return [] | 
