home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 149569350

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
149569350 MDU6SXNzdWUxNDk1NjkzNTA= 834 open_dataset error, "UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' .." 742403 closed 0     4 2016-04-19T20:06:04Z 2016-07-24T02:55:41Z 2016-07-24T02:55:41Z NONE      

I have a netcdf file I downloaded. When I try to open it with open_dataset (using version 0.7.0, with Python 2.7, on a Jupyter notebook), I get this fatal error: UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 752: ordinal not in range(128) (the full stack trace is below)

I couldn't find any references to this error in xarray, either on this list or Google. The only somewhat/indirectly related github issue I found might be #681 (closed).

Using ncdump and the netCDF4 package, I'm almost certain the problem is a non-ascii long dash character in the "Abstract" global attribute. netCDF4 doesn't throw an error when opening the file or viewing the Abstract attribute.

None of the open_dataset parameters seem relevant to this issue.

Any tips? I can now get at the data using netCDF4, but I'd prefer to have the convenience of xarray datasets. The only way I can think of is to first create a new version of the nc file where I drop the offending global attribute.

``` python ds = xray.open_dataset(os.path.join(pth, 'Aragonite.nc'))


UnicodeEncodeError Traceback (most recent call last) /home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/IPython/core/formatters.pyc in call(self, obj) 697 type_pprinters=self.type_printers, 698 deferred_pprinters=self.deferred_printers) --> 699 printer.pretty(obj) 700 printer.flush() 701 return stream.getvalue()

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj) 381 if callable(meth): 382 return meth(obj, self, cycle) --> 383 return _default_pprint(obj, self, cycle) 384 finally: 385 self.end_group()

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/IPython/lib/pretty.pyc in default_pprint(obj, p, cycle) 501 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs: 502 # A user-provided repr. Find newlines and replace them with p.break() --> 503 _repr_pprint(obj, p, cycle) 504 return 505 p.begin_group(1, '<')

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/IPython/lib/pretty.pyc in repr_pprint(obj, p, cycle) 692 """A pprint that just redirects to the normal repr function.""" 693 # Find newlines and replace them with p.break() --> 694 output = repr(obj) 695 for idx,output_line in enumerate(output.splitlines()): 696 if idx:

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/xarray/core/dataset.pyc in repr(self) 790 791 def repr(self): --> 792 return formatting.dataset_repr(self) 793 794 @property

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/xarray/core/formatting.pyc in dataset_repr(ds) 274 summary.append(vars_repr(ds.data_vars, col_width=col_width)) 275 if ds.attrs: --> 276 summary.append(attrs_repr(ds.attrs)) 277 278 return '\n'.join(summary)

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/xarray/core/formatting.pyc in _mapping_repr(mapping, title, summarizer, col_width) 208 summary = ['%s:' % title] 209 if mapping: --> 210 summary += [summarizer(k, v, col_width) for k, v in mapping.items()] 211 else: 212 summary += [EMPTY_REPR]

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/xarray/core/formatting.pyc in summarize_attr(key, value, col_width) 191 def summarize_attr(key, value, col_width=None): 192 # ignore col_width for now to more clearly distinguish attributes --> 193 return ' %s: %s' % (key, _maybe_truncate(value)) 194 195

/home/mayorga/miniconda/envs/bigcz/lib/python2.7/site-packages/xarray/core/formatting.pyc in _maybe_truncate(obj, maxlen) 183 184 def _maybe_truncate(obj, maxlen=500): --> 185 s = str(obj) 186 if len(s) > maxlen: 187 s = s[:(maxlen - 3)] + '...'

UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 752: ordinal not in range(128) ```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/834/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 79.147ms · About: xarray-datasette