Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV export fails #395

Closed
markhahnfeld opened this issue Apr 25, 2016 · 4 comments · Fixed by #432
Closed

CSV export fails #395

markhahnfeld opened this issue Apr 25, 2016 · 4 comments · Fixed by #432
Labels
!deprecated-label:bug Deprecated label - Use #bug instead

Comments

@markhahnfeld
Copy link

markhahnfeld commented Apr 25, 2016

CSV export fails with the following stacktrace:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_appbuilder/security/decorators.py", line 26, in wraps
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/caravel/models.py", line 1164, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/caravel/views.py", line 515, in explore
    payload = obj.get_csv()
  File "/usr/local/lib/python2.7/dist-packages/caravel/viz.py", line 282, in get_csv
    return df.to_csv(index=include_index)
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 1343, in to_csv
    formatter.save()
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/format.py", line 1550, in save
    self._save()
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/format.py", line 1651, in _save
    self._save_chunk(start_i, end_i)
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/format.py", line 1677, in _save_chunk
    lib.write_csv_rows(self.data, ix, self.nlevels, self.cols, self.writer)
  File "pandas/lib.pyx", line 1078, in pandas.lib.write_csv_rows (pandas/lib.c:19848)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)
@andrewhn
Copy link
Contributor

andrewhn commented Apr 25, 2016

I think the fix should be a matter of adding encoding='utf-8' as an argument to DataFrame.to_csv here.

Would be nice to have a unicode datasource to test these issues with.

@jacopoch
Copy link

jacopoch commented Apr 25, 2016

@markhahnfeld, @andrewhn alternatively you could do something like adding:

 import sys
 sys.setdefaultencoding("utf-8")

to caravel/viz.py, it should do the trick. But we'll need to make a PR to fix the problem.

@andrewhn
Copy link
Contributor

My preference would be not to use setdefaultencoding for these reasons.

I plan to add a unicode data source for testing in the next couple of days.

@mistercrunch
Copy link
Member

Yeah if we can sprinkle some unicode in the unit tests that would help.

@mistercrunch mistercrunch added the !deprecated-label:bug Deprecated label - Use #bug instead label Apr 27, 2016
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 17, 2021
Bumps [yeoman-generator](https://github.com/yeoman/generator) from 4.8.2 to 4.9.0.
- [Release notes](https://github.com/yeoman/generator/releases)
- [Commits](yeoman/generator@v4.8.2...v4.9.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 24, 2021
Bumps [yeoman-generator](https://github.com/yeoman/generator) from 4.8.2 to 4.9.0.
- [Release notes](https://github.com/yeoman/generator/releases)
- [Commits](yeoman/generator@v4.8.2...v4.9.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 25, 2021
Bumps [yeoman-generator](https://github.com/yeoman/generator) from 4.8.2 to 4.9.0.
- [Release notes](https://github.com/yeoman/generator/releases)
- [Commits](yeoman/generator@v4.8.2...v4.9.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 26, 2021
Bumps [yeoman-generator](https://github.com/yeoman/generator) from 4.8.2 to 4.9.0.
- [Release notes](https://github.com/yeoman/generator/releases)
- [Commits](yeoman/generator@v4.8.2...v4.9.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants