blaze / blaze/odo

odo fails with UTF-8 encoded csv file

Open
#446 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1k
Forks
131
PR merge metrics
No merged PRs in 30d

Description

The following code

```
import logging

from odo import (discover, odo, resource)

logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('')

resource_uri = 'data.csv'

try:
dshape = discover(resource(resource_uri))
except IOError:
log.exception('File {} not found '.format(resource_uri))
raise
except NotImplementedError:
log.exception('Not sure how to parse {}'.format(resource_uri))

odo(resource_uri, 'sqlite:///db.db::table', dshape=dshape, encoding='utf-8')

log.info('Ending')
```

Will fail for `UTF-8` encoded csv.

In `datashare.coretypes` the following code will make it work

```
def print_unicode_string(s):
try:
try:
return s.decode('unicode_escape').encode('ascii')
except UnicodeEncodeError:
return s.encode('utf-8')
except AttributeError:
return s
```

however it has the `utf-8` enconding harcoded, instead of being the one specified in the `odo` call, in this case being `utf-8`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.